Q:

mail header in php not working

Please help me, I am having problems with sending an html formatted mail message using php mail()
I think the problem lies in the header. I have included two headers with a slight difference only in single quotes or double quotes:
header 1:
$headers = 'From: webmaster@example.com\r\n Reply-To: webmaster@example.com';
$headers .= '\r\nContent-Type: multipart/alternative; boundary="'.$random_hash.'"'; 

When I use single quotes like above, all my html code is printed in the mail as simple text without th proper html formatting. Also my header is shown all messed up with everything after \r\n missing.
header 2:
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"".$random_hash."\"";

Using this one, I get a perfect header but now my mail is sent empty with an empty attachment. I don't where that comes from as I don't attach anything to my mail.
Please suggest what to do

A:

If you use single quotes on your PHP strings escape characters like \r\n will stop working.
I'm not sure how to help with your attachment without more context.

A:

I don't like php mail.  I recommend use XpertMailer: http://www.xpertmailer.com/ do an excellent work.

A:

Use a library
Don't reinvent the wheel if you can't make it round.
Use a library!

