简体   繁体   中英

PHPmailer Font Styles Not Working

Edit :: I just figured out the answer to my own question. It seems it only understands <span style="..."></span> tags and no other type of font tag.

Thanks anyway! ^^


Original question:

I've successfully got PHPmailer working. Everything works except font styles. If I do something like this, the font isn't affected when the email appears in my inbox.

isHTML is set to true already btw.

$mail->Body = '
      <html>
      <body style="font-family: Verdana, Geneva, sans-serif; font-size:12px; color:#FF0000;">
      Testing Fonts
      </body>
      </html>';

I also tried doing a tag instead of putting it in the body tag

<font style="font-family: Verdana, Geneva, sans-serif; color:#FF0000;">Testing Fonts</font>

When I receive the email (I've tried emailing to my gmail, yahoo, as well as my company email which is accessed using Outlook), the font that it's displayed in is the default font with whatever email client is viewing it.

For example on Outlook, it is displayed in Times New Roman and black instead of Verdana and red.

Does anyone know what I'm doing wrong? :(

Thanks!

http://www.w3schools.com/tags/tag_font.asp states clearly:

The tag is not supported in HTML5. Use CSS instead.

So, use a style sheet:

<head>
<style>
span {
   font-family: Verdana, Geneva, sans-serif; 
   font-size:12px; 
   color:#FF0000;
}
</style>
</head>

But remember, that the fonts that you wish to use should be present on the receiving computer. If you use sc=p

In addition to your style="font-family: Verdana, Geneva, sans-serif;" attribute try adding face="Verdana, Geneva, sans-serif" to your font tag

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