How to set DSN (Delivery Status Notification) for PHPMailer?

别说谁变了你拦得住时间么 提交于 2019-12-06 03:45:41

I discovered that PHPMailer doesn't support DSN, so I had to amend class.smtp.php itself.

Original Code:

fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);

Change to:

 fputs($this->smtp_conn,"RCPT TO:<" . $to . "> NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;" . $to ."" . $this->CRLF);

As for directing DSN to other than sender address, this can be achieved by defining:

 $mail->Sender = "bounced@email.com";

I just test,it work for me, modify class.smtp.php

Original Code:

public function recipient($toaddr)
{
    return $this->sendCommand(
        'RCPT TO',
        'RCPT TO:<' . $toaddr . '>',
        array(250, 251)
    );
}

for example, Change to:

public function recipient($toaddr)
{
    return $this->sendCommand(
        'RCPT TO',
        'RCPT TO:<' . $toaddr . '> NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;',
        array(250, 251)
    );
}

How would this be done in the latest version of phpmailer where there is no fputs($this->smtp_conn,"RCPT TO:<" . $to . "> etc. line within the smtp file anywhere that I can see?

Closest to it, that I can see is the only place RCPT TO is mentioned.

public function recipient($toaddr)
{
    return $this->sendCommand(
        'RCPT TO',
        'RCPT TO:<' . $toaddr . '>',
        array(250, 251)
    );
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!