0

I am using simple mail() function to send mails, and everything works fine tile I supply a header info, as shown below:

$headers  = "MIME-Version: 1.0\r\n";    
                            $headers.= "Content-type: text/html; carset=iso-8859-1;\r\n";   
                            $headers.= "From: TESTSITE <".$mailfrom.">\r\n";

Also, on another note, my cpanel server doesn't show the msg log, so I can't exactly figure out why the mail failed. But for one thing, I am quite sure the problem is due to the inclusion of the header, any ideas what could be wrong and how to debug?

mps_sudip
  • 49
  • 1
  • 1
  • 5
  • @Ash Burlaczenko: cause, if I do something like `if(mail(....)) { } else { }` It executes the else part – mps_sudip Sep 05 '11 at 10:31
  • There are very good mail libraries that you could use instead of mail(), just the better ones: Swiftmailer, Zend_Mail, PHPMailer. Check them out. – Maerlyn Sep 05 '11 at 10:35
  • Looks like there are many other questions similar to yours, try looking at: - http://stackoverflow.com/questions/609764/mail-headers - http://stackoverflow.com/questions/566182/complete-mail-header-php – Larry Sep 05 '11 at 10:26

2 Answers2

0

You have a mistake: carset=iso-8859-1 shuld be charset=iso-8859-1.

Also due to PHP - mail() manual : " If messages are not received, try using a LF (\n) only instead of CRLF (\r\n). Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822."

s.webbandit
  • 16,332
  • 16
  • 58
  • 82
0

Well, without any tests, I can tell you that your 2.º line has a mistype:

Content-type: text/html; carset=iso-8859-1

should be:

Content-type: text/html; charset=iso-8859-1

Zuul
  • 16,217
  • 6
  • 61
  • 88