views:

519

answers:

7

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.

+2  A: 

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

Charlie Martin
Thats not what I am looking for.. what should the source code look like? Should there be an <html> tag around the email or not? etc.. should I set a doctype as stated in my question
Thomaschaaf
Yes it is. RTF RFC.
Charlie Martin
Not really I don't find it.. its just talking about how the parts are defined not whether its w3c conform html or anything or if the "base" tags have to exist..
Thomaschaaf
+4  A: 

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.

Jeroen Landheer
so you're saying I do need an html tag and body and head etc and the example zend provides is invalid?
Thomaschaaf
Jeroen Landheer
Note: Outlook 2007 uses Word for HTML rendering, not IE.
Neil Williams
A: 

I agree with Jeroen regarding styling your HTML email in the file itself rather than referencing an external .css file. I have had problems in the past.

Mike C.
+4  A: 

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.

stesch
+4  A: 

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

neezer
+1 for the mailchimp link. I've been looking for an email previewer.
Neil Aitken
+3  A: 

Most of webclients (like gmail) won't grab external stylesheets at all, likely because it could impose a security risk.

We standardize on text-only emails for any critical email (for example email activation after registration). For marketing emails we mainly work with in-line styles, tables, and anything that was popular on the web in the 90's.

Email html has not made the same progression as web email, try to stick with absolute basics.

Evert
A: 

Writing HTML email that will work in all email clients is almost impossible. Expect to use many workarounds to support all of them. If you want to see which email clients support web standards the best then visit email standards.org. They have a list of email clients and the HTML and CSS support they offer.

Andrew Marsh