简体   繁体   English

PHP的邮件功能-如何更改标题中的发件人:不发送电子邮件?

[英]php mail function - how can changing From: in header cause email not to be sent?

The one email From:support@lead.com works fine. 发一封电子邮件来自:support@lead.com可以正常工作。 But when changed to john.doe@lead.com it doesn't work? 但是,当更改为john.doe@lead.com时,它不起作用吗? See below. 见下文。

Both are valid email addresses (fictitious for this example) in the domain from which they are sent. 两者都是在其发送域中的有效电子邮件地址(在此示例中为虚拟)。

I have the question into Netfirms support too. 我也有对Netfirms支持的问题。 I expect to move to phpmailer or API to a ESP (eg, mailchimp) account soon, but this is just bugging me that the little change breaks the email function. 我希望很快就可以将phpmailer或API转移到ESP(例如mailchimp)帐户,但这只是让我感到困惑,因为一点点改动都破坏了电子邮件功能。

Code: 码:

Works: 作品:

$headers = "Mime-Version: 1.0\n"; 
$headers .= "Content-Type: text/html;charset=UTF-8\n"; 
$headers .= 'From: support@lead.com' . "\r\n"; 
$headers .= 'Bcc: bcc@lead.com' . "\r\n";   
//   $headers .= 'Return-Path: bcc@lead.com' . "\r\n";  
mb_internal_encoding("UTF-8"); 
if (!mail($to, $subject, $body, $headers, "-f bcc@mylead.com")) echo ("Message delivery failed"); 

Doesn't Work: (only changed support to john.doe): 不起作用:(仅更改对john.doe的支持):

$headers = "Mime-Version: 1.0\n"; 
$headers .= "Content-Type: text/html;charset=UTF-8\n"; 
$headers .= 'From: john.doe@lead.com' . "\r\n"; 
//   $headers .= 'Return-Path: bcc@lead.com' . "\r\n";  
mb_internal_encoding("UTF-8"); 
if (!mail($to, $subject, $body, $headers, "-f bcc@lead.com")) echo ("Message delivery failed"); 

不知道这到底有多重要,但是您在标头中混合了\\ n和\\ r \\ n,这可能会使您的邮件服务器感到困惑……您介意尝试一下吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自电子邮件的php mail()与我通过标头发送的邮件不同 - php mail() from email not the same as what I sent through header 如果从php mail()函数发送的电子邮件返回,它在linux中的位置? - If an email sent from php mail() function returns, where is it located in linux? 使用邮件功能php发送了多少电子邮件 - how many email have been sent using mail function php 如何隐藏php邮件发送的电子邮件中的“收件人”字段 - How can I hide the 'to' field in the email sent by php mail PHP的邮件功能说,电子邮件发送,但剂量 - php mail function says Email sent but it dosent 如何自定义从php mail()脚本发送的电子邮件的方式 - How to customize the way an email looks sent from a php mail() script 在php邮件功能中我们可以将From属性设置为Word Not Email吗? - in php mail function Can we set From attribute as a Word Not Email? 为什么 html 没有显示在我使用 php mail() function 发送的 email 中? - Why html not showing in the email i sent using php mail() function? 自定义php邮件功能发送的邮件中的from字段 - Customizing the from field in the mail sent from php mail function 使用PHP的mail()函数发送电子邮件时,如何自定义“发件人”字段? - How can I customize the 'From' field when sending and email with PHP's mail() function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM