[英]Exim overwrites “from” header when sending MIME email from PHP
I'm using the PHP Pear Mail_Mime library to send email. 我正在使用PHP Pear Mail_Mime库发送电子邮件。 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. 在运行Mac OS X的服务器上,这一切都可以正常运行(尽管我不确定100%肯定使用sendmail作为邮件程序。)在发送测试电子邮件时,“发件人:”字段显示正确的发件人。
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. 但是,如果我在使用Exim4作为邮件程序的Linux服务器上运行相同的脚本,则仍会发送电子邮件,但默认情况下会显示“发件人:”标头,而不是我在脚本中指定的标头。
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. 我尝试为PHP的邮件功能在“其他参数”中设置“ -f [来自电子邮件地址]”选项,但这似乎没有效果。
Can anyone tell me how I might get the from header to work properly with Exim? 谁能告诉我如何从from标头中正常使用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 = "wtf@domain.com";
$to = "wtf@domain.com";
$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 wtf@domain.com -r wtf@domain.com");
print_r($result);
?>
You're sending via the command line (vs. SMTP). 您是通过命令行(相对于SMTP)发送的。 Exim only allows trusted senders to use the -f
option. Exim仅允许受信任的发件人使用-f
选项。 Either: 或者:
Add the user sending the mail to the trusted user list in the exim config, which would look something like this: 将发送邮件的用户添加到exim配置中的受信任用户列表,如下所示:
trusted_users = root:apache:www:exim:60001 Trusted_Users = root:apache:www:exim:60001
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.