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 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算