views:

52

answers:

3

Hi,

Is there anything I need to be aware of when creating a HTML e-mail? Is it as simple as creating a valid HTML page then sending it via PHP? Or do I need to use tables to ensure it display's correctly.

Any advice to get this right first time would be much appreciated.

A: 

Tables is bad...but the correct way to go in emails... Also send only the part you would normally put in the body and only use inline css. Another important thing is that background images most of the time dont work.

This is a very good guide that can help you out.

my advice: test in a lot of browsers,mailclients and email programs

red-X
+2  A: 

Creating an HTML email that displays the way you want to in email clients, can be very difficult, if not impossible. Unfortunately, email clients do not use the latest and greatest web browsers when displaying emails, and they can also restrict what should be allowed (and with good reasons).

No matter how much you might love CSS-based layouts, table-based layout is still the way to go for HTML emails. You can still use CSS for other things, of course, but in some cases it will need to be inline. The best looking HTML emails I've seen, are largely made up of tables and big images - simply because unlike on normal web pages it is nigh on impossible to create the equivalent using good web development practices. HTML email is a world of its own.

You should also test the emails in as many email clients as you can - and while it can be cumbersome to install all the different clients, you can also use services such as Litmus, MailChimp and CampaignMonitor (see also this question). Personally I have had good experiences with Litmus.

Good luck, creating HTML emails can be quite messy!

vetler
+1  A: 

Tables are definitely the best option for HTML emails, since most other methods tend to display differently on different machines.

Things to watch out for:

  • Images are often blocked by email programmes - try to use background colours where possible
  • Don't link to an external stylesheet - put the styles in <head>. This will prevent your server being hit when the emails are opened.

There's also a good blog post from Mailchimp about using CSS in HTML emails.

What
I believe even the <head> is stripped by web-based email, like Gmail, so inline css needs to be in the <body>.
flashparry