我通过在 /etc/hostconfig 中添加以下行来配置 Snow Leopard 上的 Postfix:
MAILSERVER=-YES-
然后,我将 postfix 配置为通过我的 ISP 的 SMTP 服务器进行中继。我在 /etc/postfix/main.cf 中的相应位置添加了以下两行:
myhostname = 1and1.com
relayhost = shawmail.vc.shawcable.net
然后我有一个简单的 PHP 邮件函数包装器,如下所示:
send_email("[email protected]", "[email protected]", "Test Email", "<p>This is a simple HTML email</p>");
echo "Done";
function send_email($from,$to,$subject,$message){
$header="From: <".$from.">
";
$header.= 'MIME-Version: 1.0' . "
";
$header.= 'Content-type: text/html; charset=iso-8859-1' . "
";
$send_mail=mail($to,$subject,$message,$header);
if(!$send_mail){ echo "ERROR"; }
}
有了这个,我收到了一封格式似乎不正确的电子邮件。邮件标题显示在电子邮件正文中。原始邮件内容如下:
Return-Path: <[email protected]>
Delivery-Date: Tue, 27 Apr 2010 18:12:48 -0400
Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9])
by mx.perfora.net (node=mxus2) with ESMTP (Nemesis)
id 0M4XlU-1NCtC81GVY-00z5UN for [email protected]; Tue, 27 Apr 2010 18:12:48 -0400
Message-Id: <[email protected]>
Received: from pd6ml3no-ssvc.prod.shaw.ca ([10.0.153.149])
by pd6mo1no-svcs.prod.shaw.ca with ESMTP; 27 Apr 2010 16:12:47 -0600
X-Cloudmark-SP-Filtered: true
X-Cloudmark-SP-Result: v=1.0 c=1 a=VphdPIyG4kEA:10 a=hATtCjKilyj9ZF5m5A62ag==:17 a=mC_jT1gcAAAA:8
a=QLyc3QejAAAA:8 a=DGW4GvdtALggLTu6w9AA:9 a=KbDtEDGyCi7QHcNhDYYwsF92SU8A:4
a=uch7kV7NfGgA:10 a=5ZEL1eDBWGAA:10
Received: from unknown (HELO 1and1.com) ([24.84.196.104])
by pd6ml3no-dmz.prod.shaw.ca with ESMTP; 27 Apr 2010 16:12:48 -0600
Received: by 1and1.com (Postfix, from userid 70)
id BB08D14ECFC; Tue, 27 Apr 2010 15:12:47 -0700 (PDT)
To: [email protected]
Subject: Test Email
X-PHP-Originating-Script: 501:test.php
Date: Tue, 27 Apr 2010 18:12:48 -0400
X-UI-Junk: AutoMaybeJunk +30 (SPA);
V01:LYI2BGRt:7TwGx5jxe8cylj5nOTae9JQXYqoWvG2w4ZSfwYCXmHCH/5vVNCE
fRD7wNNM86txwLDTO522ZNxyNHhvJUK9d2buMQuAUCMoea2jJHaDdtRgkGxNSkO2
v6svm0LsZikLMqRErHtBCYEWIgxp2bl0W3oA3nIbtfp3li0kta27g/ZjoXcgz5Sw
B8lEqWBqKWMSta1mCM+XD/RbWVsjr+LqTKg==
Envelope-To: [email protected]
From: <[email protected]>
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
Message-Id: <[email protected]>
Date: Tue, 27 Apr 2010 15:12:47 -0700 (PDT)
<p>This is a simple HTML email</p>
以下是发送电子邮件后我的 /var/log/mail.log 文件的内容:
Apr 27 15:29:01 User-iMac postfix/qmgr[705]: 74B1514EDDF: removed
Apr 27 15:29:30 User-iMac postfix/pickup[704]: 25FBC14EDF0: uid=70 from=<_www>
Apr 27 15:29:30 User-iMac postfix/master[758]: fatal: open lock file pid/master.pid: unable to set exclusive lock: Resource temporarily unavailable
Apr 27 15:29:30 User-iMac postfix/cleanup[745]: 25FBC14EDF0: message-id=<[email protected]>
Apr 27 15:29:30 User-iMac postfix/qmgr[705]: 25FBC14EDF0: from=<[email protected]>, size=423, nrcpt=1 (queue active)
Apr 27 15:29:30 User-iMac postfix/smtp[747]: 25FBC14EDF0: to=<[email protected]>, relay=shawmail.vc.shawcable.net[64.59.128.135]:25, delay=0.21, delays=0.01/0/0.1/0.1, dsn=2.0.0, status=sent (250 ok: Message 25784419 accepted)
Apr 27 15:29:30 User-iMac postfix/qmgr[705]: 25FBC14EDF0: removed
办公室里还有两个人也遵循了完全相同的过程,并且运行了完全相同的脚本、snow leopard 版本、php 等,一切都运行正常。我甚至将他们的配置文件复制到我的机器上,重新启动了 postfix,重新启动了 apache,但都无济于事。
有人知道我可以采取什么步骤来解决这个问题吗?这让我很困惑...
谢谢
答案1
是的,正如 taspeotis 提到的,我通过从 php.ini 中删除“mail.add_x_header = On”行来修复它
我会看看是否可以将其标记为答案。