1

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

$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: admin@domain.com' . "\r\n";
$headers .= 'Reply-To: Admin <admin@domain.com>' . "\r\n";

// Return Path - 
$return_path = "bounce@domain.com";

$toUser... (all necessary variables)

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

我测试了几封电子邮件,例如 abXXX@kasbkjasbdka.com、8hgb87@9ndksjc9ne.com

(等等,所有无效的、不存在的电子邮件地址)

为什么它不去我的bounce@domain.com????

4

3 回答 3

1

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

$headers .= "Return-Path: bounce@domain.com\r\n";
于 2009-06-22T12:36:45.950 回答
0

您需要在 之后添加一个空格-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: admin@domain.com' . "\r\n";
$headers .= 'Reply-To: Admin <admin@domain.com>' . "\r\n";

// Return Path
$return_path = 'bounce@domain.com';

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

if(mail($toUser, $subject, $body, $headers, '-f ' . $return_path)) {
 echo 'res=sent';
} else {
 echo 'res=error';
}
于 2009-06-22T09:36:41.837 回答
0

这可能是由您的 sendmail 的配置引起的。-F参数作为命令行属性通过管道传递,因此需要配置 sendmail 以支持它。

来自php.net

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

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

于 2009-06-22T09:39:04.327 回答