我有一个带有最新存储库(apt-get)后缀的 ubuntu 12.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", $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);
}
然后to@example.com
AND MAILER-DAEMON(我在我aliases
的 中设置为 root)收到电子邮件。
mail
由 mailutils命令读取时的 MAILER-DAEMON 电子邮件是:
Return-Path: <from@example.com>
Delivered-To: MAILER-DAEMON@localhost
Received: by localhost (Postfix, from userid 33)
id 5663254EB; Wed, 15 May 2013 16:57:52 +0700 (ICT)
To: to@example
Subject: Test
X-PHP-Originating-Script: 1000:mail_func.php
From: FromMe <from@example.com>
MIME-Version: 1.0
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: base64
Message-Id: <20130515095752.5663254EB@localhost>
Date: Wed, 15 May 2013 16:57:52 +0700 (ICT)
然后是 base64 电子邮件。如何防止 MAILER-DAEMON 在通过 PHP 发送电子邮件时收到副本?