PHPMailer反弹邮件没有得到正确的反弹

n00*_*00b 0 php email phpmailer bounce

我写了一个PHP脚本,它发送邮件.我是从"mail@something.com"发送的,并且还将"返回路径"设置为"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();
Run Code Online (Sandbox Code Playgroud)

我如何强制退回的邮件转到退回邮件帐户?谢谢你的帮助!

Syn*_*hro 10

不要使用ReturnPath- Sender而是设置.ReturnPath最近在PHPMailer(版本5.2.8)中禁用了对该属性的支持,因为在发送时将其设置为无效.接收方在接收消息时添加返回路径,并通过将所需的返回路径放入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();
Run Code Online (Sandbox Code Playgroud)

  • 这个对我有用,$ mail-> Sender ='bounce@xxxxxxxx.nl'; 如此可怜,你的答案不被接受...... (2认同)