The header does not display correctly on email PHP e-mail

advertisements

I have the following code to send my emails:

$EmailFrom= "[email protected]";
$EmailTo = "[email protected], [email protected]";
$Subject = "Contact The Loft";

$success = mail($EmailTo, $Subject, $Body, $EmailFrom);

When I submit my form it sends the mail correctly but on my email the header is not displayed correctly. Look the following image:

I do not want [email protected] be displayed as the header, so that is why i search thru google and i found out that i need to customize my header. So i did the follow, but now the email is not sent. it seems there is something wrong with the headers:

<?php
$EmailFrom= "From: HudsonLofts <[email protected]>\r\n";
$EmailFrom.= "X-Mailer: PHP/" . phpversion()."\r\n";
$EmailFrom.= "MIME-Version: 1.0" . "\r\n";
$EmailFrom.= "Content-type: text/html; charset=iso-8859-1 \r\n";
$EmailTo = "[email protected], [email protected]";
$Subject = "Contact The Hudson Loft";

And this is where i call the mail function:

$success = mail($EmailTo, $Subject, $Body, $EmailFrom);

When i submit the form and check my email account not email is received.

I will appreciate your help. Thanks in advance

I have realized that when i use FROM: the mail is not sent. Moreover the mail function does not work it returns false. BUT it i remove FROM and just use: HudsonLofts then it works but the headers it is not displayed properly on my email :(


See http://php.net/manual/function.mail.php
Try to use \n instead of \r\n in $EmailFrom.

BTW: I would rename $EmailFrom to $additionalHeaders ;-)

EDIT after comment:
If this doesn't work, try just with this one line for the headers:
$EmailFrom = "MIME-Version: 1.0";

Second guess: Omit the \r\n at the last header line.