我正在尝试找出使用PHPMailer时如何设置DSN。 我知道在SMTP协议级别,DSN是在RCPT TO之后指定的,例如RCPT TO:NOTIFY=成功,失败 ORCPT=rfc822;recipientemail@gmail.com
另外,如果可能的话,我想将DSN定向到发件人地址以外的地址。 感谢任何指示,谢谢。
我发现PHPMailer不支持DSN,所以我不得不修改class.smtp.php本身。
原始代码:
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
更改为:
fputs($this->smtp_conn,"RCPT TO:<" . $to . "> NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;" . $to ."" . $this->CRLF);
至于将DSN定向到发件人地址以外的地址,这可以通过定义以下方法来实现:
$mail->Sender = "bounced@email.com";
我只是测试,它对我有用,修改class.smtp.php
原始代码:
public function recipient($toaddr)
{
return $this->sendCommand(
'RCPT TO',
'RCPT TO:<' . $toaddr . '>',
array(250, 251)
);
}
例如,更改为:
public function recipient($toaddr)
{
return $this->sendCommand(
'RCPT TO',
'RCPT TO:<' . $toaddr . '> NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;',
array(250, 251)
);
}
在没有 fputs($this->smtp_conn,"RCPT TO:<" 的最新版本的 phpmailer 中如何做到这一点。 $to ."> sptp 文件中我能看到的任何地方的行
?离它最近的,我可以看到唯一提到RCPT TO的地方。
public function recipient($toaddr)
{
return $this->sendCommand(
'RCPT TO',
'RCPT TO:<' . $toaddr . '>',
array(250, 251)
);
}
我发现了在PHPMAiler上设置DSN的官方命令:
$mail->DSN = '成功,失败,延迟';
可以按时使用这三个命令,也可以隔离使用。
前任:
$mail = new PHPMailer(true);
$mail->dsn = 'SUCCESS';
默认情况下,命令 SUCCESS 和 FAILURE 在服务器上处于启用状态,但 SUCCESS 是启用"传递状态通知"(Notificação de Status de Entrega)返回所必需的。
注意: 验证"PHPMailer.php"的第 343 行以获取更多说明。