dongniechi7825 2011-02-18 21:44
浏览 69
已采纳

带有特定服务器的php函数邮件的附加标题问题

I have an email function in php:

function send_mail($to, $from, $objet, $message) {
$entetemail  = 'MIME-Version: 1.0' . "
";  
$entetemail .= 'Content-type: text/plain; charset=UTF-8' . "
";  
$entetemail .= 'From: '.$from. "
";  
$entetemail .= 'Cc: ' . "
";  
$entetemail .= 'Bcc: ' . "
";  
$entetemail .= 'Reply-To: '.$from .''. "
";  
$entetemail .= 'X-Mailer: PHP/' . phpversion() . "
" ;  
$entetemail .= 'Date: '. date("D, j M Y H:i:s -0600");  
return mail($to, $objet, $message, $entetemail);  
}

$to is a valid email address. $from looks like:

Firstname name <email@example.com>

$objet and $message come respectivelly from an input texte and a textarea.

I've got no PHP errors and mail send me false back.

After an echo, my header looks like on bothe servers:

MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
From: Firstname Name 
Cc: 
Bcc: 
Reply-To: Firstname Name 
X-Mailer: PHP/4.4.9
Date: Fri, 18 Feb 2011 23:35:58 -0600

On my local server everything is fine. But on the production one, the From line gives an issue because of the $from variable. The email will not be send. Have I done something wrong? Is there a server configuration which break everything?

  • 写回答

1条回答 默认 最新

  • doudi1978 2011-02-18 22:52
    关注

    It in fact does work.

    I just did all my tests with fake email addresses. It seems the production server didn't like it but my local didn't care.

    I'd like to know how, but I'll see this later.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号