开发者

Additional header problems with php function mail with a particular server

开发者 https://www.devze.com 2023-02-12 12:56 出处:网络
I have an email function in php: function send_mail($to, $from, $objet, $message) { $entetemail= \'MIME-Version: 1.0\' . \"\\r\\n\";

I have an email function in php:

function send_mail($to, $from, $objet, $message) {
$entetemail  = 'MIME-Version: 1.0' . "\r\n";  
$entetemail .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";  
$entetemail .= 'From: '.$from. "\r\n";  
$entetemail .= 'Cc: ' . "\r\n";  
$entetemail .= 'Bcc: ' . "\r\n";  
$entetemail .= 'Reply-To: '.$from .''. "\r\n";  
$entetemail .= 'X-Mailer: PHP/' . phpversion() . "\r\n" ;  
$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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消