我写了一个发送邮件的PHP脚本。我是从“mail@something.com”发送的,并且还将“Return-Path”设置为“bounce@something.com”,但我仍然收到邮件发送邮件给邮件(“mail@something.com” “)。
以下是代码:
$this->mail = new PHPMailer();
$this->mail->isSMTP();
$this->mail->Host = 'host';
$this->mail->SMTPAuth = true;
$this->mail->Username = 'mail@something.com';
$this->mail->Password = 'pass';
$this->mail->SMTPSecure = 'tls';
$this->mail->Port = 25;
$this->mail->ReturnPath = 'bounce@something.com';
$this->mail->From = 'mail@something.com';
$this->mail->send();
我如何强制退回的邮件转到退回邮件帐户?谢谢你的帮助!
答案 0 :(得分:9)
请勿使用ReturnPath
- 设置Sender
。最近在PHPMailer(版本5.2.8)中禁用了对ReturnPath
属性的支持,因为在发送时设置它是无效的。接收方在收到消息时添加返回路径,并通过将所需的返回路径放入Sender
属性进行设置,该属性在SMTP会话期间作为信封发送方传递。当您致电Sender
时会自动设置setFrom
,但您可以覆盖它并直接设置它,如下所示:
$this->mail = new PHPMailer();
$this->mail->isSMTP();
$this->mail->Host = 'host';
$this->mail->SMTPAuth = true;
$this->mail->Username = 'mail@something.com';
$this->mail->Password = 'pass';
$this->mail->SMTPSecure = 'tls';
$this->mail->Port = 25;
$this->mail->setFrom('mail@something.com');
$this->mail->Sender = 'bounce@something.com';
$this->mail->send();
答案 1 :(得分:0)
将此行添加到您的代码中:
/home/person1/index.html