是否有办法设置返回路径时发送邮件通过认证 SMTP使用PHP?我希望跳出邮件被另一个电子邮件地址捕获,而不是"from"地址。
我知道有一种方法可以用"正常"PHP mail()函数(通过在第5个参数中设置"-f"标志)来做到这一点,但我不知道如何用SMTP来管理这个。
还尝试了PEAR的Mail-package,但是在header中设置Return-path不起作用。
设置第四个mail()
参数(additional_headers
)为"Return-path:mybouncereceiver@example.com"
。
的例子:
$to = "to@example.com";
$from = "from@example.com";
$bounce = "mybouncereceiver@example.com";
$subj = "mysubject";
$message = "blah";
$headers = "From:$from'r'nReturn-path:$bounce"
mail($to, $subj, $message, $headers);
您可以看到您使用'r'n
(换行符)分隔多个additional_headers
。
参见:http://php.net/manual/en/function.mail.php
您需要这样做。
你需要在标题中设置'Return-Path'到你想要使用的电子邮件。这对我很有效。
例如:
$headers['From'] = 'richard@example.com';
$headers['To'] = 'joe@example.com';
$headers['Subject'] = 'Test message';
$headers['Return-Path'] = 'bounce@example.com';