简体   繁体   中英

GMail doesn't mark up email html (sending via PHP)

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?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM