HTML Email Guide
Last modified: March 14th, 2008
This HTML Email Guide contains tips and tools on how to create compatible HTML email which will display correctly on most webmail and email clients.
HTML email or HTML newsletters have advantages and disadvantages. But your clients (recipients) decide if you will send them a HTML email or a plain text email. For example if they specifically sign up for a HTML newsletter.
The following have been tested on Windows:
- Webmail - Hotmail, Windows Live Hotmail, Gmail, Yahoo! Mail, Lycos Mail
- Email clients - Outlook 2003, Thunderbird 1.5
- Browsers - Internet Explorer 6 and 7, Mozilla Firefox 2
Testing for Mac will be added soon (Apple Mail, Entourage, Hotmail, Gmail, Yahoo! Mail, Lycos Mail, Firefox, Safari).
It’s recommended to have a look at the Email Standards Project who strive for standards support in email clients. You can find extensive and thorough tests for popular email clients.
Translations
- Software for creating HTML email
- Software for sending HTML email
- Get several webmail accounts for testing
- Create an effective layout
- Remove unnecessary HTML tags
- Use tables for layout
- Put all images online
- Hide the image toolbar
- Use absolute urls
- Use short urls
- Use simple inline style sheets
- Create your design with a white background color
- Avoid background images defined on the body
- All text and links must have a style
- Use the title and alt attribute
- Use <BR> instead of <P>
- Use spacers
- Choosing a maximum width
- Don’t use forms
- Don’t use Javascript
- Provide an unsubscribe link
- Provide a link for an online version
- Provide extra functionality for the online version
- Test your design in multiple browsers
- Avoid your HTML email being marked as spam
- Don’t use DHTML
- Don’t use Flash
- Use HTML Email Validator
- Use HTML Tidy Online
- Count the number of clicks in your HTML email with tracking
- Remove duplicated email addresses
- Send HTML email with PHPMailer
- Send your email as multipart/alternative
- Email clients are more flexible
- Forwarding HTML email
- Read More
Software for creating HTML email
There are a lot of editors available you can use. Here are a few tools you can use to create HTML email and websites:
- Codetch (WYSIWYG editor / free / Firefox extension)
- PSPad (universal editor, alternative for UltraEdit / free)
- Intype (source code editor / free)
- NVU (open source WYSIWYG editor / free)
- Macromedia Dreamweaver (WYSIWYG editor / not free)
To upload your files you can use FireFTP (Firefox extension) and/or FileZilla.
Don’t use Microsoft Word to create HTML pages or HTML email
The reason is Word will write a whole lot of garbage when you create HTML pages with it. For example, I created a HTML page in Word and only put this line of text in it: “Don’t use Word to create HTML files”. Then I saved it as a HTML file. Show/Hide the HTML that Word 2003 created.
Other versions of Microsoft Word also create garbage. But all you need is:
<p>Don't use Microsoft Word to create HTML files</p>
Don’t copy/paste from Microsoft Word
Microsoft Word uses a different kind of formatting of the text than for example Notepad, Notepad++, PSPad and Dreamweaver. These programs all work in text mode without formatting.
Software for sending HTML email
Zookoda
Zookoda enables you to:
- Manage email newsletter subscribers.
- Create custom newsletter subscription forms.
- Schedule recurring broadcasts for each day, week or month.
- View real-time open, bounce, click and unsubscribe reports.
- Access mobile users by emailing content in text format.
Just register for free and get started. You can find a step by step tutorial (flash) which guides you to create and send a HTML newsletter. Unfortunately the tutorial goes very fast and there are no controls.
As part of Zookoda’s anti-spam commitment, to comply with the CAN SPAM Acts of 2003/2004, all new members are restricted from sending emails until each account’s details are manually verified. Once your logged in, go to Account > Sender Details > New Sender. Here you can fill in your address information. You can also view here if your email address and address information are verified. If it’s rejected, you will receive an email. For more information, have a look at Zookoda Verifications.
poMMo
poMMo is a versatile mass mailing application for Linux which is written in PHP. I haven’t tested it out yet, but it looks very promising. Have a look at the poMMo screenshots (Flickr slideshow).
PHPlist
PHPlist is an open source newsletter manager. It is highly configurable and offers a lot of features such as click-tracking, templates, subscribe/unsubscribe, user management, advanced bounce handling, scheduling, throttling and a lot more.
No knowledge of PHP is required to install PHPlist. The most important thing is to configure config.php.
Dada Mail - Mailing List Manager
Dada Mail is very customizable, easy to use and contains a lot of features like unlimited number of mailing lists, templates, archives including search engine, control panel for each mailing list and administration. Dadamail can be given extra functionality by using extensions such as the Mystery Girl - Bounce Handler. No knowledge of Perl/CGI is required to install DadaMail. Some extensions require knowledge of using Linux.
MailList Controller
Arclab Maillist Controller manages email lists and sends out (personalized) bulk email in html, plain text or html and plain text. Contains a WYSIWYG editor, customizable returned mail detection and a comprehensive control panel. This is a free application for which you can use one mailinglist only and a maximum up to 100 recipients.
Thunderbird
Mozilla Thunderbird is an email application which is able to send messages as plain text, HTML email and a combination of HTML email and plain text. Create a new message, click in the body field and choose Insert > HTML…
PHPMailer
PHPMailer is a full featured email application for PHP.
- HTML email
- Embedded image support
- Multipart/alternative emails for mail clients that do not read HTML email
- Can send emails with multiple TOs, CCs, BCCs and REPLY-TOs
- Works on any platform
- Go to the website of PHPMailer for more features
Get several webmail accounts for testing
Testing, testing and testing. Before sending out your HTML email, you have to make sure it looks good on several webmail clients. Get yourself several webmail accounts:
Besides webmail accounts you also need to have email clients to test your HTML email:
- Mozilla Thunderbird (PC, Mac)
- Microsoft Outlook 2003, 2007 (PC)
- Entourage (Mac)
- Apple Mail (Mac)
Create an effective layout
The layout of the HTML email and the writing style are very important. You want people to read your newsletter, not to scan it. You want to draw their attention to headlines, etc. EyeTrackIII deals with online news consumer behavior in the age of multimedia. On their website you can find an incredible load of information about Article page design, Writing style, Eyetracking, how to create hot spots and many many more.
Remove unnecessary HTML tags
The following HTML tags should be removed from your HTML email, because several webmail applications and email clients are removing or ignoring these tags.
- DOCTYPE
- HTML tag
<HTML></HTML> - BODY tag
<BODY></BODY> - All Meta tags
<META> - Head tag
<HEAD></HEAD> - Base tag
<BASE> - Link tag
<LINK> - Script tag
<SCRIPT></SCRIPT> - Title tag
<TITLE></TITLE> - Applet tag
<APPLET></APPLET> - Frameset tag
<FRAMESET></FRAMESET> - Frame tag
<FRAME> - IFrame tag
<IFRAME></IFRAME> - Comments
<!-- comments -->
Use tables for layout
Because of the very limited support of style sheets in webmail clients, the best and safe way to layout your HTML email is to use tables.
Put all images online
In your HTML email you can use embedded images or remote images.
Embedded images are attached with the email itself and are shown immediately.
Remote images are images which are located on a remote website, but are not displayed at first. In today’s webmail and email clients you have to click on a link to display the remote images. If the email address of the sender is in the address book of the recipient, then the images in the HTML email will be shown.
Images from an unknown sender aren’t displayed at first because they are considered unsafe because of several security issues (e.g. spammers can validate your email address, hijack your email account, etc.). The HTML email should be as small as possible in size (KB’s). Using remote images results in very few KB’s and therefore less bandwidth when sending it.
Hide the image toolbar
If you put your mouse over an image in Internet Explorer, the image toolbar appears. This only occurs if your image is larger than 200 x 200 pixels and when it’s not a background image.
Most people find the image toolbar annoying, but it also distracts the reader from your content. To hide the image toolbar for an image, use the galleryimg attribute in the <IMG> tag:
<img src="cd.gif" width="20" height="30" galleryimg="no" alt="CD of group X" title="Order this CD">
Use absolute urls
Use absolute urls for all your images and links, for example:
<img src="http://www.example.com/images/head.gif" width="20" height="60">
<a href="http://www.example.com/products/shoes/tiger.html">Tiger</a>
Use short urls
When using long urls you risk getting broken links or broken images. Your email program or the email program of your recipient could wrap the long URL along several lines. This can cause part of the url to be clickable instead of the whole url:
http://www.example.com/very_long_name/5r6t/2003fd544/3553ag
dkgj3d/a453b96/g5?a=36hd27hdh48f27dh
Webmail clients can also add a space (%20) when a url is too long:
<img src="http://www.example.com/mailings/2005/april/17/header_top_disc%20ount.jpg" width="230" height="45" title="Discount at ...">
To avoid this use short urls:
<img src="http://www.example.com/2004/11/images/1.jpg" width="10" height="60">
<a href="http://www.example.com/2004/11/index.html">Go to discounts</a>
This code can be rewritten to:
<img src="http://www.example.com/2004/11/1.jpg" width="10" height="60">
<a href="http://www.example.com/2004/11/">Go to discounts</a>
Keep the following in mind when you want to use a short url:
- Don’t use an images directory. Place the images in the same directory as the index.html (newsletter);
/images/1.jpgbecomes/1.jpg - Use numbers as names for pictures;
header_cd.jpgbecomes1.jpg. - Rename
spacer.giftos.gif - If you use a link in your newsletter to refer to an online version of your newsletter, then you will mostlikely use a tracking variable in the url. For example:
http://www.example.com/2004/11/index.html?trck=nov1104.
You can rewrite this to for examplehttp://www.example.com/2004/11/?trck=nov1104
Snipurl can also help by shortening your url. Just enter a url and Snipurl will shorten it by given you a new url that will never expire. There are
several services like this (tinyurl and Make A Shorter Link), but Snipurl can do a lot more. Take a look at what you can do with Snipurl.
Use simple inline style sheets
Use simple style sheets, that means not to use absolute or relative positioning. This is bad supported by most webmail. Don’t use external or embedded style sheets, because email programs are removing or ignoring everything between the <HEAD></HEAD>. That means the <LINK> tag won’t work if you want to define external style sheets.
Use inline stylesheets for fonts, font colors, links, background colors, etc. For example:
<table width="400" cellspacing="0" cellpadding="0">
<tr>
<td style=”font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 150%; color: red”>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
<p>Vivamus ut sem. Fusce aliquam nunc vitae purus.</p>
</td>
<td style=”font-family: Verdana, Helvetica, sans-serif; font-size: 10px; text-transform: uppercase; color: black”>
Vivamus ut sem. Fusce aliquam nunc vitae purus.</td>
</tr>
</table>
Create your design with a white background color
Most webmail and email clients use a white background color to display messages. Often webmail clients ignore or remove the <BODY> tag, which is why background colors often don’t work.
When you do use a diferent background color than white you could mess up your design. This could for example happen if you create your design for a red background. Images may have a red background. When viewed in a webmail client, you mostlikely will see a white background and images with a red background that doesn’t seamlessly integrate with the background color.
The best thing to do is to create your design with a white background color. If you must use a different background color than white, you can use a table with a 100% width and perhaps 100% height to simulate the background color:
<table width="100%" height="100%">
<tr>
<td bgcolor=”#FF0000″>
<table width=”400″ align=”center”>
<tr>
<td>Lorem ipsum dolor sit amet consectetuer</td>
</tr>
</table>
</td>
</tr>
</table>
Unless you know for sure your target audience is using an email client such as Outlook or Thunderbird, a background color can be used without problems. For example if your sending HTML email to employers within a company who all use the same email client.
Avoid background images defined on the body
As already mentioned webmail clients often ignore or remove the <BODY> tag, which is why background images often don’t work.
Unless you know for sure your target audience is using an email client such as Outlook or Thunderbird, a background image can be used without problems. For example if your sending HTML email to employers within a company who all use the same email client.
All text and links must have a style
You have to specify the font, font color and the font size for all the text and links in every table cell
(create your design with tables). If you don’t specify a style, then most webmail clients will use their own style sheets. This could result in displaying different fonts, font colors and sizes and could also mess up your design.
Hotmail and Yahoo display Arial as the default font if you don’t specify a font. Gmail uses Verdana. Hotmail uses a 11px
as the default font size, Yahoo uses 12px and Gmail uses 16px.
Below is an example. This is the minimum of style sheets required to style text and links.
<table width="400" cellspacing="0" cellpadding="0">
<tr>
<td style=”font-family: Verdana, sans-serif; font-size: 11px; color: black”>
<p><a href=”http://www.website.com/030205/” style=”font-family: Verdana, font-size: 11px; color: blue”>Lorem</a>
ipsum dolor sit amet, consectetuer adipiscing elit.</p></td>
<td style=”font-family: Verdana, sans-serif; font-size: 10px; color: black”>Vivamus ut sem. Fusce aliquam nunc vitae purus.</td>
</tr>
</table>
I always use text-decoration: underline to make it clear to
the reader that it’s a link:
<a href="http://www.website.com/030205/" style="font-family: Verdana, font-size: 11px; color: blue; text-decoration: underline">Lorem</a>
Email addresses and URLs as text
In most cases when using an email address or an URL as text it will be given a default style. For example:
Send all your questions to contact@example.com
Go to http://www.example.com for more information
Go to www.example.com for more information
Go to sub.example.com for more information
Gmail and Yahoo give all the above text a default style even though they aren’t links. Hotmail and Windows Live Hotmail don’t give default styles to URLs without http://.
Use the title and alt attribute
Use the alt attribute to describe your images except spacers. The alt text is displayed when images aren’t being displayed. Image aren’t displayed by default by most webmail and email clients.
The title attribute can be just for almost any element (links, images, tables, etc.). Use the title attribute if you want to display a tooltip to describe the element. It is recommended to use it for links and images. For example:
<img src="cd.jpg" width="170" height="230" alt="Kool Keith CD - black elvis" title="The new Kool Keith CD>
<a href=”http://www.website.com/order.php?id=23″ title=”Order the new Kool Keith CD”>Order CD</a>
Move your mouse over this link to view a tooltip.
Use <BR> instead of <P>
The <P> tag in Internet Explorer uses more space (margin-top and margin-bottom) than in Gecko-based browsers. This could lead to layout problems.
For example, if you’re using a table width a fixed width and height and your design is based upon these dimensions. If you have content in the table within <P> tags, than the height of the table could increase in Internet Explorer which could lead to gaps in your design.
To prevent layout problems use the <BR> tag instead of the <P> tag as it renders the same in all browsers. If you still have troubles with the layout you can also use spacers instead of the <P> and the <BR> tag.
Another problem with <P> tags is in Windows Live Hotmail. <P> tags are removed. So the safest way is to use the <BR> tag.
Use spacers
Use 1×1 transparent images (spacers) to force tables to display the correct width and height. For example:
<table width="200">
<tr>
<td width=”50″> </td>
<td width=”150″>Lorem ipsum dolor sit amet adipiscing.</td>
</tr>
</table>
The table cell with a width of 50 pixels only has a space as content. This doesn’t mean the specified width will be displayed correctly. If the width of the first table cell isn’t displayed
correctly, than this is mostlikey also the case width the second table cell.
You have to force the width to be displayed correctly:
<table width="200">
<tr>
<td><img src=”http://www.yourwebsite.com/images/spacer.gif” width=”50″ height=”1″></td>
<td><img src=”http://www.yourwebsite.com/images/spacer.gif” width=”150″ height=”1″></td>
</tr>
<tr>
<td> </td>
<td>Lorem ipsum dolor sit amet adipiscing.</td>
</tr>
</table>
Choosing a maximum width
Choosing a width mostly applies to webmail clients. When you double click on an email in Outlook or Thunderbird, you can almost view it full screen.
With a resolution at 1024×768 you can use a maximum width of 750px. But you can also use a higher width. If you use a higher width (for example 800px) at 1024×768 a horizontal scrollbar could appear in your webmail client. But this doesn’t have to be a problem, because all of your content is still visible. Perhaps you have to scroll a little in horizontal direction.
With a resolution at 800×600 you can use a maximum width of 580px. But again, you can also use a higher width which could show a horizontal scrollbar. If you open your Hotmail account at 800×600 a horizontal scrollbar will appear no matter wich width you use. I guess
this is because of the ad banner (sky scraper, 160×600px) on the right and the large banner (super banner, 728×90) at the top.
Le cool magazine demonstrates this with an horizontal design of their weekly newsletter.
Don’t use forms
Hotmail ignores forms in HTML email to ensure that messages do not contain malicious scripts. Other webmail services (Gmail and Yahoo) and email clients support the use of forms.
If you intend on sending HTML emails with a form and amongst your recipients are also people with a Hotmail email address, than I would recommend not using a form. Instead use a link to refer to a form on a HTML page.
Don’t use JavaScript
JavaScript in HTML email is never a good idea because of all the dangerous scripting (for example XSS attacks) that can be executed. For this reason most webmail and email clients disable JavaScript by removing or ignoring it.
For example, this code:
<a href="javascript://" onclick="window.open('http://www.website.com/cd.html','','width=500,height=400')">View tracklisting</a>
would be rewritten to:
<a href="#">View tracklisting</a>
The solution is to refer to the tracklisting without JavaScript.
<a href="http://www.yourwebsite.com/discount/cd.html">View tracklisting</a>
Provide an unsubscribe link
At the bottom of every HTML email you should provide an unsubscribe link. After clicking on this link (mailto:) the recipient only has to press on the send button to remove their email address from a list, for example:
mailto:unsubscribe@domain.com?subject=unsubscribe
You can also let people unsubscribe from your website. But doing so gives people the possibility to unsubscribe other people. If you only provide this functionality from your HTML email, then you have less chance that unsubscribing will be misused.
Provide a link for an online version
Although you test your HTML email with different webmail and email clients, you never can be sure how it will display in your recipients email program. In case it doens’t display correctly provide a link at the top of every HTML email to view your HTML email in the browser for an online version, for example:
if this email doesn't display correctly, view the online version
The example link used here is http://www.example.com/mailings/2005/01/. Use structured directories, so you can archive all your HTML emails easily.
Use the <TITLE> tag in the online version. If you omit the tag in the online version, Internet Explorer will show the url as the title.
Provide extra functionality for the online version
The HTML email is put online so that the online version can be viewed when it doesn’t display correctly in webmail or an email clients. But you can also change your design and put the content online. You then have for example a design with a graphic and text link. The text link is in case the images won’t load. When the link is clicked the viewer will end up in the online version.
Now you have different possibilities. You can use hover (mouseover) for all the links, (streaming) video/audio, you can use advanced CSS to easily create complex designs and afcourse scripting (PHP, JavaScript, AJAX, etc.) and database access.
This way you don’t have the limitations of HTML email in webmail and email clients but the unlimited possibilities of HTML email in the browser.
Test your design in multiple browsers
Check the statistics for your website so you can see which browsers are the most popular among your visitors. If you want to test your design in multiple browsers on a Windows machine then you have several options.
Standalone browsers
The easiest options are to use standalone browsers like Mozilla Firefox and Opera. With Firefox you can easily test simultaneously in Internet Explorer 6 or 7 with the Firefox extensions IE Tab and IEView. Here is a huge list of browsers you can download at the Browser archive.
Standalone versions of Internet Explorer
With Windows XP as the most popular operating system, so is Internet Explorer 6 and 7. The problem is if you want to use older versions of Internet Explorer (4.0 and 5.0) then you also have to install the older Windows versions. Luckily there is a workaround for this, standalone versions of Internet Explorer.
Mac browsers
Most people don’t have a Mac to test their design on. You can use the Safari Compatibility Test. Just enter a url and the Safaritest will return a screenshot of your page as viewed with Safari.
Linux browsers
Testing your design in a Linux browser can be done with a Linux LiveCD. A Linux LiveCD is Linux installed on a bootable CD-ROM or DVD-ROM. When booting from a Linux LiveCD you can start applications, create documents, etc. without anything being written or saved to the hard disk.
The most popular LiveCDs are Ubuntu and Knoppix. Download the LiveCD (ISO), burn it on a CD-ROM (with Infrarecorder), put it in your CD/DVD player and reboot. Here is a list of available Linux LiveCDs.
Avoid your HTML Email being marked as spam
A substantial part of your subscribers are probably still using Hotmail or Windows Live Mail. To get your newsletter arrive in the inbox of your Hotmail/Windows Live Mail subscribers is still the hardest thing to accomplish. Read this document from Microsoft titled “Improving E-mail Deliverability into Windows Live Hotmail” (26 pages, 1,02 MB).
Don’t use DHTML
Dynamic HTML uses a combination of Javascript, HTML and CSS. It is not recommended to use DHTML because JavaScript is disabled by most webmail clients and email clients.
Don’t use Flash
When you try to use Flash in your HTML email the HTML code gets removed or ignored by webmail and email clients.
The best thing to do is to put your Flash movie online. Then in your HTML email create an attractive clickable image that refers to the Flash movie online. Also put above or under the clickable image a text link with text from the image. Because images are not displayed by
default, the recipient will see the text first. Unless your address is in the address book of the recipient.
Use HTML Email Validator
Use the HTML Email Validator to see if your HTML is compatible for HTML email. Just copy and paste your HTML into the validator and it will report if there are any errors. Each error will refer to a section in
this article that will explain the error.
Use HTML Tidy Online
Use HTML Tidy Online to clean up your HTML code. This decreases the incorrect display of your HTML email. Click on the advanced
link on the right to use advanced HTML Tidy options. View a quick reference of the configuration options.
Now you can choose your settings to optimize your HTML email code. Unfortunately there isn’t an option to save your settings. You have to manually set them each time you visit HTML Tidy Online.
HTML Tidy Settings
You can download a extension that automatically loads settings to optimize HTML email at HTML Tidy Online. This extension was created with Greasemonkey compiler. Install HTML Tidy Settings
GreaseMonkey user script
You could also use a GreaseMonkey user script. I have written a GreaseMonkey user script that will automatically load settings to optimize HTML email at HTML Tidy Online. Greasemonkey is a Firefox extension that allows you to write scripts that alter the web pages you
visit. To load the HTML Tidy settings first install GreaseMonkey. View this page for instructions. After you’ve installed GreaseMonkey you can install the user script that loads the HTML Tidy settings.
- Click on this link to view the user script in Firefox
- Go to Tools > Install User Script …
- A dialog will pop up with the name of the script
- Click OK to install the user script
- Go to HTML Tidy Online and the settings will be automatically loaded
Count the number of clicks in your HTML email with tracking
Usually an url will be opened when recipients click on a link in your HTML email. When a HTML page (or an image, js file, css file, etc.) on your website is requested, information about this request will be logged in a logfile called Access_log.
Statistic programs use your Acces_log to show information about visitors of your website. An typical line in the Access_log looks like the following:
63.203.109.38 - - [02/Sep/2003:09:51:09 -0700] "GET /custer HTTP/1.1"
301 248 “http://search.msn.com/results.asp?RS=CHECKED&FORM=MSNH&
v=1&q=%22little+big+Horn%22″ “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”
You can use the Acces_log to determine how many times there has been clicked on a specific link in a specific HTML email. This can be done with variables. If you have the following link in your HTML email that refers to a page with products:
http://www.example.com/products/shoes/page.html
You can add variables to this url. The first variable is separated with a ?-character. If you want to add variables then you need a variable name and a value. I’m going to add a variable name track with the value shoes20050411 (you can use whatever name and value you prefer):
http://www.example.com/products/shoes/page.html?track=shoes20050411
If you have shell access (command line) and access to the Access_log, then you can count for example how many times there has been clicked on the above link. You can do this with Linux commands like grep, sort, uniq, etc. If you wanted to track more variables, then you use the &-character:
http://www.example.com/products/shoes/page.html?track=shoes20050411&color=blue
Another useful function is to track how many recipients clicked on the link to display the HTML email in the browser. Which means it didn’t display correctly in their webmail client or email
program. Then you can measure how many people didn’t see it correctly:
http://www.example.com/mailings/2005/01/index.html?track=online200501
It doesn’t matter what variable name or value you use. Just as long as you know what it stands for.
Remove duplicated email addresses
You can find it here.
Send HTML email with PHPMailer
- Go to the website of PHPMailer and download the latest version.
- Unpack PHPMailer and upload it to your website.
- Copy and paste the following code in a php file (e.g. test.php) and upload it to your website:
<?php require(”class.phpmailer.php”); $mail = new PHPMailer(); $mail->From = “namesender@name.com”; $mail->FromName = “Firstname Lastname”; $mail->AddBCC(’namerecipient1@name.com’, ‘John Doe1′); $mail->AddBCC(’namerecipient2@name.com’, ‘John Doe2′); $mail->AddBCC(’namerecipient3@name.com’, ‘John Doe3′); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = “Here is the subject”; $mail->Body = “<<<HTMLCODE <p>Copy and paste your <b>HTML code</b> here</p> HTMLCODE; if(!$mail->Send()) { echo “Message could not be sent. <p>”; echo “Mailer Error: ” . $mail->ErrorInfo; exit; } echo “Message has been sent”; ?> - Open the php file online, e.g.:http://www.website.com/phpmailer/test.php
- You should see “Message has been sent”.
Send your email as multipart/alternative
If you send a HTML email to people with a webmail or email client who can’t read HTML email, they will only see the HTML code. If you don’t know what your recipients use, send your email as multipart/alternative. This is the HTML version and the plain text version.
The email program of the recipient decides which version it will show. If it doesn’t support HTML email, it will show the plain text version. If it does support HTML email, it will show the HTML version.
Send multipart/alternative email with PHPMailer
Follow the same steps as Send HTML email with PHPMailer. The only difference is one line of code. Add the following code after $mail->Body:
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
Email clients are more flexible
If you know for sure your target audience uses a standalone email program such as Outlook or Thunderbird (or another) than it’s easier to create a HTML email.
You have far less limitations than a webmail client:
- you can use embedded style sheets (css in the head)
- you can use forms (not recommended)
- you can use a background color
- you can use a background image
- you can use absolute positioning
- you can use meta tags
Forwarding HTML email
When people receive a email they like they’ll usually forward it to a friend. So when your HTML formatted email is forwarded it is important that it still looks the same.
Forwarding HTML email works with Gmail, Yahoo, Hotmail, Lycos and SquirrelMail. To make it work you have to forward it as an attachment or just forward the HTML email.
Read More
- Email Standards Project
- Essential Guides (PDFs)
- Adventures in Email Marketing
- The Messaging Times
- Email Marketing Metrics Report - (PDF, 2,87 MB)
- Tamara’s Email Marketin Best Practices Blog
- The Email Wars
- Email Marketing Voodoo
- Newsletter Archive
- Email Marketing Reports
- VerticalResponse Email Marketing Blog
- EmailStatCenter: The Leading Authority on Email Marketing Metrics
- Email Marketing Articles - EmailLabs
- Campaign Monitor Blog
- MailChimp Blog