Jump to content

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


gordon.c

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 protected];

  $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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.