gordon.c Posted February 7, 2013 Share Posted February 7, 2013 Hi, so I have a script that sends out HTML emails written in PHP. The code must be fine because the HTML content renders well when sent to Gmail account or even to other major email providers. There is however one local email provider that cant display the exact same email content. Instead displays HTML code in plain text. What went wrong? $to = email@email.com; $boundary = uniqid('np'); $subject = RemoveCzech($_POST['subject']); $message = "\r\n\r\n--" . $boundary . "\r\n"; $message .= "Content-type: text/html;charset=utf-8\r\n\r\n"; $message .= "<h2>".$_POST['subject']."</h2>"; $message .= TransformTags($_POST['content']); $message .= "<br /><br /><br /><br /><p>Pokud si přejete pozastavit zasílání emailů, můžete tak provést - <a href='".$path."/contact'>zde</a></p>"; $message .= "\r\n\r\n--" . $boundary . "--"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "From: ".RemoveCzech(SITE_NAME)." <podpora@".RemoveCzech(SITE_NAME).">\r\n"; $headers .= "Subject: ".$subject."\r\n"; $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n"; mail($to, $subject, $message, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/274152-html-emails-fail-with-some-email-providers-but-are-fine-with-gmail-and-other-major-ones/ Share on other sites More sharing options...
Christian F. Posted February 7, 2013 Share Posted February 7, 2013 (edited) Noting went wrong, per se. It's just that the e-mail client in question either can't parse HTML, or is set up to never do so. Make your e-mails multi-part and send a text-only version of content in the mail as well. Then the ones who are using text-only e-mail readers will be able to see your content, without all of the HTML tags, as well. Edited February 7, 2013 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/274152-html-emails-fail-with-some-email-providers-but-are-fine-with-gmail-and-other-major-ones/#findComment-1410733 Share on other sites More sharing options...
gordon.c Posted February 7, 2013 Author Share Posted February 7, 2013 Well if I use pretty much the same code to send such email from a different domain (website) it works fine. I am really suspecious about either some META tags that might be missing or some other aspect of the website that takes care of character sets. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/274152-html-emails-fail-with-some-email-providers-but-are-fine-with-gmail-and-other-major-ones/#findComment-1410737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.