PHP+;后缀:所有电子邮件都复制到mailer守护进程
我有一个带有最新存储库(apt get)后缀的Ubuntu12.10盒。当我从PHP+;后缀:所有电子邮件都复制到mailer守护进程,php,postfix-mta,Php,Postfix Mta,我有一个带有最新存储库(apt get)后缀的Ubuntu12.10盒。当我从sendmail命令行发送电子邮件时: sendmail -r from@example.com -f from@example.com -t to@example.com 该电子邮件仅发送至to@example.com(这很好) 但是,当我使用PHP和此函数时: function mymail($to, $subject, $message, $frommail = "from@example.com", $fro
sendmail
命令行发送电子邮件时:
sendmail -r from@example.com -f from@example.com -t to@example.com
该电子邮件仅发送至to@example.com
(这很好)
但是,当我使用PHP和此函数时:
function mymail($to, $subject, $message, $frommail = "from@example.com", $fromname = "From Me") {
$subject = "=?utf-8?B?" . base64_encode($subject) . "?=";
$from = $fromname . " <" . $frommail . ">";
$headers = "From: " . $from . " \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n\r\n";
$message = base64_encode($message);
$param = "-r " . $frommail . " \r\n";
// Optionally tried also
// $param = "-r " . $frommail . " -f " . $frommail . " \r\n";
mail($to, $subject, $message, $headers, $param);
}
然后是base64电子邮件。
如何防止MAILER-DAEMON在通过PHP发送电子邮件时收到副本?我不确定是否应该删除此问题,或者让它作为将来的帮助。我刚找到原因。在额外的参数中,我应该使用
$param = "-f" . $frommail;
没有“\r\n”
而不是错误的:
$param = "-r " . $frommail . " \r\n";
$param = "-r " . $frommail . " \r\n";