mail() not working with some headers

Hello,

I’m using mail() to send html e-mails but in some servers they e-mail is not sending when using:
$headers .= ‘From: ‘.$from.’ <’.$contact.’>’."\r\n";

I think the problem is ‘<’, ‘>’ because when I just use ‘From: something’ it sends the email but I get “From: [email protected]”…

Here is my header:

$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
$headers .= ‘From: ‘.$from.’ <’.$contact.’>’."\r\n";

mail($email, $subject, $body, $headers, “-f$contact”);

I’ve tried several things but it only works with “From: $from”…

Am I doing something wrong?

Thanks for your help.

Oh, if it helps, my website is on cheapname hosting…

On some servers \r\n in message headers will not work. Try to use just \n (new line). The < and > chars should not be a problem.

Sponsor our Newsletter | Privacy Policy | Terms of Service