Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does an HTML E-Mail look like?

I am trying to automatically build html emails and am trying to figure out whether there are standards and what attributes in an email work and which have to exist. Do I need a ? And if no does there have to be a body? Do I need to specify what Doctype I am using?

I am working with the Zend Framework in their example they don't set anything but the content with "styling" code http://framework.zend.com/manual/de/zend.mail.html-mails.html

Just so you know why I do need HTML. This seesm stupid but our company is writing support software and the one critical "bug" or feature request all out beta testers was basic HTML so they can highlight important words by making them fat, italic, underlined etc.

like image 513
Thomaschaaf Avatar asked Apr 03 '09 21:04

Thomaschaaf


4 Answers

Coding for HTML email I've always found to be a crap shoot. Unlike browsers, few mail clients adhere to W3C standards for HTML markup. MailChimp's a pretty sweet service that will let you preview your HTML emails in 30 some odd email clients, including web-based ones.

They also have a guide freely available containing some valuable do's and don'ts.

In short, inline CSS is going to be your best bet (especially with web clients that will strip out certain CSS). Tables are more reliable for styling in this case (though, being a standards warrior, I cringe to say it).

As for html and body tags - I send them in my emails. You're guiding principal should be KISS (keep it simple, stupid!).

like image 158
neezer Avatar answered Sep 29 '22 11:09

neezer


HTML for email is essentially the same as HTML for the web. The difference is that your email message is being treated like being in the untrusted restricted zone, which means you cannot use javascript or any other scripting technologies.

You can embed attachments in the mail (like images, style sheets, and so on) or reference them from an external source. Fact is that if you reference them from an external source, most email readers will not download them without the approval of the user. This means that often it is better to put CSS between style tags in the header and images like inline attachments.

When reading mail in ThunderBird or Outlook, obviously there are differences. One uses the rendering engine of FireFox, one uses IE's engine. This is the same as making pages for the web.

If you take those points into account, you should be able to make nice looking email messages without a problem.

Hope this helps.

like image 41
Jeroen Landheer Avatar answered Sep 29 '22 11:09

Jeroen Landheer


Don't forget to include a text version. This helps people who don't want HTML e-mails.

And speaking of not wanting HTML e-mails: HTML is often used for spam, so it's possible that more e-mails get filtered than with text only versions.

like image 28
stesch Avatar answered Sep 29 '22 09:09

stesch


You're looking for MIME-type encoding. It's a standard for wrapping HTML (among other things) so mail programs can transport it.

like image 36
Charlie Martin Avatar answered Sep 29 '22 09:09

Charlie Martin