I've problem with sending HTML mails with PHPMailer. I make a Smarty template and I got all the HTML code from it. But when I send mail, I got the mail without included CSS (it's only background-color, font or something like that). In PHPMailer I set that the mail is HTML.
Is there any way to send HTML mail with included CSS?
How is your stylesheet referenced?
For email you will either have to provide an absolute path to your stylesheet or include the styles in the head of the template
Here is a really good SitePoint article on HTML emails, "How to Code HTML Email Newsletters".
CSS support in e-mail is very limited, at least. The biggest issue is that different clients support different sets of CSS-properties.
You provide very little context for us to work with.
For more information on CSS support in e-mail, please refer to this excellent overview.
There's is a way...
That code will generate an HTML output in $body like this:
The
CSSQuery
class can be found at phpclasses.org. This implementation is based on the fact that most webmails will only allow to add style by an inline tag attribute style and not through style tags or link tags.It's pretty much limited and with a restricted syntax because of the regular expression it's kind of simple, but it's still better than write by your own the inline style attributes in each HTML tag.
I assume you have your CSS in an external file, if so the easiest solution would be to simply move it into the html header inside the mail.
However, css support in email clients is very wonky, so it might just be crappy rendering on their part.
I've found the best (read broadest) support for CSS is inline (style=""). Sad, but true.