Jump to content

HTML emails fail with some email providers but are fine with gmail and other major ones


Recommended Posts

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);

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 by Christian F.

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.