Exim 会覆盖“from”从 PHP 发送 MIME 电子邮件时的标头
我正在使用 PHP Pear Mail_Mime 库发送电子邮件。在我的脚本中,我在发送消息之前设置了“From:”标头。这一切在运行 Mac OS X 的服务器上运行良好(可能使用 sendmail 作为邮件程序,尽管我不是 100% 确定)。发送测试电子邮件时,“发件人:”字段显示正确的发件人。
但是,如果我在使用 Exim4 作为邮件程序的 Linux 服务器上运行相同的脚本,电子邮件仍会发送,但“发件人:”标头显示为默认标头,而不是我在脚本中指定的标头。
我尝试在PHP的邮件功能的“附加参数”中设置“-f [来自电子邮件地址]”选项,但这似乎没有效果。
谁能告诉我如何让 from 标头与 Exim 正常工作?
非常感谢任何建议。
干杯, 汤姆
编辑:这是代码,以防有人有兴趣查看它。
<?php
include_once('Mail.php');
include_once('Mail/mime.php');
$subject = "mime mail test";
$from = "[email protected]";
$to = "[email protected]";
$visitor_email = $from;
$message = new Mail_mime();
$message->setTXTBody("hallo there!");
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$result = $mail->send($to, $headers, $body, "", "-f [email protected] -r [email protected]");
print_r($result);
?>
I'm using the PHP Pear Mail_Mime library to send email. In my script, I set the "From:" header before sending the message. This all works fine on a server running Mac OS X, (which presumably uses sendmail as the mailer, although I'm not 100% sure.) When sending a test email, the "From:" field shows the correct sender.
However, if I run the same script on a Linux server with Exim4 as the mailer, the email is still sent but the "From:" header shows up as a default instead of the one I specified in the script.
I've tried setting the "-f [from email address]" option in the "additional parameters" for PHP's mail function, but this seems to have no effect.
Can anyone tell me how I might get the from header to work properly with Exim?
Any advice is greatly appreciated.
Cheers,
Tom
EDIT: here's the code in case anyone is interested in looking at it.
<?php
include_once('Mail.php');
include_once('Mail/mime.php');
$subject = "mime mail test";
$from = "[email protected]";
$to = "[email protected]";
$visitor_email = $from;
$message = new Mail_mime();
$message->setTXTBody("hallo there!");
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$result = $mail->send($to, $headers, $body, "", "-f [email protected] -r [email protected]");
print_r($result);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您通过命令行发送(相对于 SMTP)。 Exim 仅允许受信任的发件人使用
-f
选项。要么:将发送邮件的用户添加到 exim 配置中的受信任用户列表中,如下所示:
trusted_users = root:apache:www:exim:60001
You're sending via the command line (vs. SMTP). Exim only allows trusted senders to use the
-f
option. Either:Add the user sending the mail to the trusted user list in the exim config, which would look something like this:
trusted_users = root:apache:www:exim:60001