I see:
Content-typetext/html; charset=iso-8859-1
where should i see:
Content-type: text/html; charset=iso-8859-1
Is this a cut / paste error? In your code or in your result?
Note that you probably want to include text as a multi-page message in text and text / text types, since HTML-only mail often gets high spam ratings (using SpamAssassin, SpamBouncer, etc.).
UPDATE # 1:
It seems that \r\n interpreted as two new lines instead of one. There may be different errors on different platforms when implementing SMTP. You may be able to change the end of the line to only \n . If this works with your system, do not rely on it, as it may not work on another system.
Also, consider switching to another method of sending mail. phpMailer and SwiftMailer are recommended by the PHP internal mail() function.
UPDATE # 2:
Based on Incognito's suggestion, here you can use the code to better organize the headers, as well as create part of the plaintext:
filter_var($to, FILTER_VALIDATE_EMAIL) or die("Invalid To address"); filter_var($email, FILTER_VALIDATE_EMAIL) or die("Invalid From address"); $subject = 'HTML e-mail test'; $messagetext = 'TEST in TEXT'; $messagehtml = '<html> <body> <h1>TEST</h1> <p>in HTML</p> </body> </html>';
Iβm not saying that this is the right way to do it in any way, but if you like the strategy and you think that you can save such a code without viewing it for 6 or 12 months (i.e. it makes sense at first sight) Then feel free to use or adapt it.
Disclaimer: this is unverified and sometimes I make typos ... just to keep people on their toes. :)
ghoti source share