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

时间:2014-11-05 16:57:34

标签: php email phpmailer bounce

我写了一个发送邮件的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();

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

2 个答案:

答案 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