php 使用 PHPMailer 更改返回路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3467564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing the Return-path using PHPMailer
提问by Elitmiar
Is there a way to change the return-path using PHPMailer
有没有办法使用 PHPMailer 更改返回路径
I did the following and it did not work
我做了以下,但没有奏效
$mail->AddCustomHeader('Return-path:[email protected]');
I'm using the following statement to send mails
我正在使用以下语句发送邮件
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
//Building the reporting email to report on all the mails send
echo "Message REPORT sent!\n";
}
I get the email but the return path does not change?
我收到电子邮件但返回路径没有改变?
回答by Elitmiar
The following solved the issue, I adjusted the Sender property and it worked for me. $mail->Sender = '[email protected]';
以下解决了这个问题,我调整了 Sender 属性,它对我有用。 $mail->Sender = '[email protected]';
回答by Y Talansky
the correct way to set returnpath (as of july 2013) is by using:
设置返回路径的正确方法(截至 2013 年 7 月)是使用:
$mail->ReturnPath='[email protected]';
the phpmailer source contains the following, which is why I think $mail->Sender worked
phpmailer 源包含以下内容,这就是我认为 $mail->Sender 工作的原因
if ($this->ReturnPath) {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->ReturnPath).'>');
} elseif ($this->Sender == '') {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->From).'>');
} else {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->Sender).'>');
}
回答by revoke
$mail->Sender = '[email protected]';
回答by scy
The most probable reason for this is that the mail server you're sending this mail over enforces a specific return path. This is often the case for “hosted” webspace.
最可能的原因是您发送此邮件的邮件服务器强制执行特定的返回路径。“托管”网络空间通常就是这种情况。
In that case, you don't have a lot of options. Try talking to your hoster.
在这种情况下,您没有很多选择。尝试与您的房东交谈。
回答by SimonDowdles
Instead of using the Reply-path header, try this:
不要使用 Reply-path 标头,试试这个:
$mail->AddCustomHeader('Reply-to:[email protected]');
I use the Reply-to header and have had great success even on shared spaces.
我使用 Reply-to 标头,即使在共享空间上也取得了巨大的成功。