Author Topic: mail() not working with some headers  (Read 610 times)

Aly

  • Guest
mail() not working with some headers
« on: August 17, 2010, 11:05:32 AM »
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: xxx@share.name.hosting"...

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...

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 777
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: mail() not working with some headers
« Reply #1 on: August 17, 2010, 11:13:46 AM »
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.
Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!