1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mrpx
  • 95
  • 1
  • 6
  • 1
    You'll likely need to post more code so we can see what's happening. Specifically, the part that creates your `$variables`. – drudge Feb 18 '11 at 21:47
  • Do `
    ` right before you call mail() and post what you have for localhost and your production. The $from variable is most likely wrong. Also, post any error PHP gives you.
    – Jared Farrish Feb 18 '11 at 21:50
  • I edited my posts with your requests. I don't think it will be any help. I really think it came from ther server specifically. – mrpx Feb 18 '11 at 22:41
  • What are you passing as the value of $from? Is there any difference between the mail service on the 2 different machines? What is the mail log telling you? What return value are you getting back from mail()? I would also suggest removing headers that you aren't using, like Cc and Bcc. – Oliver Feb 18 '11 at 21:51

1 Answers1

1

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.

random
  • 9,774
  • 10
  • 66
  • 83
mrpx
  • 95
  • 1
  • 6
  • 1
    Since you've answered your own question, you can Accept your own Answer so the question gets closed. – drudge Feb 18 '11 at 23:04