3

I am trying to send a html email via mail(), however gmail just displays the email as plain text, no mark up, eg:

mail("blah@blah.com", "<i>Italic Text</i>");

just appears as

<i>Italic Text</i>

Any ideas?

peterh
  • 11,875
  • 18
  • 85
  • 108
DexCurl
  • 1,683
  • 5
  • 26
  • 38

2 Answers2

3

Have you set your email headers?

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

If yes, do any other email clients have the same problem? Or is it just Gmail?

Ciaran
  • 1,904
  • 16
  • 27
0

Try it with css, the i tag is deprecated, not sure if that is causing it...

<span style='font-style:italic;'>Italic Text</span>

Or you could try using the em tag:

<em>Italic Text</em>
.
AllisonC
  • 2,973
  • 4
  • 29
  • 46
  • Semantic Markup (what you're describing) won't make any difference whatsoever here. And FWIW, using HTML 1, non-semantic tags still work just fine. Luckily, Microsoft doesn't own the web, so things are actually backwards compatible on HTML. – bpeterson76 Apr 19 '11 at 14:35
  • @bpeterson76 Email HTML support has nothing to do with web HTML compatibility. These are two *very* different things. It never hurts to try multiple approaches and see which the email client in question will render propertly. – Dan Bechard May 20 '15 at 17:31