为什么它不返回我的返回路径?

发布于 2024-07-25 07:50:38 字数 1322 浏览 1 评论 0原文

我正在使用 php,使用邮件功能:

$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Reply-To: Admin <[email protected]>' . "\r\n";

// Return Path - 
$return_path = "[email protected]";

$toUser... (all necessary variables)

if(mail($toUser,$subject,$body,$headers, "-f".$return_path)){
    echo "res=sent";
} else {
    echo "res=error";
    }

我测试了一些电子邮件,例如 [电子邮件受保护]< /a>、[电子邮件受保护]

(等等,全部无效,非现有的电子邮件地址)

为什么它不发送到我的[电子邮件受保护]? ??

I am using php, using mail function:

$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Reply-To: Admin <[email protected]>' . "\r\n";

// Return Path - 
$return_path = "[email protected]";

$toUser... (all necessary variables)

if(mail($toUser,$subject,$body,$headers, "-f".$return_path)){
    echo "res=sent";
} else {
    echo "res=error";
    }

I tested few emails like, [email protected], [email protected]

(etc, all invalid, non-existent email addresses)

Why it dont go to my [email protected]????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暗地喜欢 2024-08-01 07:50:38

您还应该能够在大多数服务器上使用标头设置返回路径:

$headers .= "Return-Path: [email protected]\r\n";

You should also be able to set the Return-Path using a header on most servers:

$headers .= "Return-Path: [email protected]\r\n";
安静被遗忘 2024-08-01 07:50:38

您需要在-f后面添加一个空格。 另外,为什么不使用 UTF-8 而不是 iso-8859-1? 尝试这个:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Reply-To: Admin <[email protected]>' . "\r\n";

// Return Path
$return_path = '[email protected]';

/*
$toUser... (all necessary variables)
*/

if(mail($toUser, $subject, $body, $headers, '-f ' . $return_path)) {
 echo 'res=sent';
} else {
 echo 'res=error';
}

You need to add a space after -f. Also, why not use UTF-8 instead of iso-8859-1? Try this:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Reply-To: Admin <[email protected]>' . "\r\n";

// Return Path
$return_path = '[email protected]';

/*
$toUser... (all necessary variables)
*/

if(mail($toUser, $subject, $body, $headers, '-f ' . $return_path)) {
 echo 'res=sent';
} else {
 echo 'res=error';
}
ぃ双果 2024-08-01 07:50:38

可能是你的sendmail的配置导致的。 -F 参数作为命令行属性通过管道传递,因此需要配置 sendmail 来支持它。

来自 php.net

additional___parameters 参数
可用于传递附加标志
作为程序的命令行选项
配置为发送时使用
邮件,由 sendmail_path 定义
配置设置。 例如,
这可以用来设置信封
使用sendmail时的发件人地址
使用 -f sendmail 选项。

编辑:我刚刚看到Matthias Bynens的答案是正确的,请参阅这个条目

It may be caused by the configuration of your sendmail. The -F parameter is piped through as a command line attribute, so sendmail needs to be configured to support it.

From php.net:

The additional___parameters parameter
can be used to pass additional flags
as command line options to the program
configured to be used when sending
mail, as defined by the sendmail_path
configuration setting. For example,
this can be used to set the envelope
sender address when using sendmail
with the -f sendmail option.

Edit: I just saw that Matthias Bynens' answer is correct, see this entry

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文