NewCodeMan
NewCodeMan

Reputation: 227

PHP email header FROM field not displaying correctly

I need help getting the FROM field in the email to be a specific email address. As of now it is coming out something like this. Looks like its grabbing info off my hosting companies server.

[email protected]

All other features of email work great. My $headers are as follows:

$to = $email;
$subject = "ORDER # $tranid";
$headers = "From: [email protected]";
$headers = "MIME-Version: 1.0";
$headers = "Content-type: text/html; charset=iso-8859-1";

PHP manual sugest this. Which is pretty much what I am doing, I think.

$headers = 'From: [email protected]' . "\r\n" .
   'Reply-To: [email protected]' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

They do use implode, but I don't think I need it the way I have mine setup:

mail($to, $subject, $message, implode("\r\n", $headers));

Tried this with no success:

$to = $email;
$subject = "ORDER # $tranid";
$headers .= "From: [email protected]";
$headers .= "MIME-Version: 1.0";
$headers .= "Content-type: text/html; charset=iso-8859-1";

Upvotes: 0

Views: 51

Answers (1)

NewCodeMan
NewCodeMan

Reputation: 227

Found the answer with the help of @chris85

$headers = "From: [email protected]\r\n". 
           "MIME-Version: 1.0" . "\r\n" . 
           "Content-type: text/html; charset=UTF-8" . "\r\n"; 

Keeps HTML format in tack and shows FROM field correctly.

Upvotes: 1

Related Questions