Creating HTML Email

Example Source Code
from
Possibilities Ezine

(click for referring article stand-alone page)

Below is the source code for the November 22, 2005 issue of the Possibilities ezine with the "Creating HTML Email" article. Below the source code is a copy of the ezine the source code produces.

Some notes about why I do certain things when I create the HTML version of Possibilities ezine:

  • Inline styling:
    I utilize inline styling because I use the same markup, copy 'n paste, as I use for the syndicated articles. (See http://willmaster.com/possibilities/syndication/ for article syndication information.)

    The syndicated articles need to have some bolding and such. Yet, I don't want to syndicate my own style sheet with the content because some publishers prefer the articles to be consistent with their design.

    That's why the inline styling. If it was only for the email, I probably wouldn't use it.

  • <table...> instead of <div...>:
    The reason I use an enclosing table instead of a div is because of my assumption that the table tag is supported better than the div tag for width constraint and positioning. It is only an assumption. I could be mistaken.

  • Linking to an external style sheet:
    This is pure laziness. I want the newsletter's style to be consistent with the parent web site, so I use the parent web site's style sheet.

    I could keep a separate version in the ezine template. But I really would rather not have to remember whenever I make a change that a duplicate change also needs to be made somewhere else.

    There have been reports that some email readers strip out everything in the HTML HEAD area of the email. In that case, the style sheet link would be stripped out. Probably I'll move the style sheet link into the body area in future issues to reduce the chance of it being stripped out.

    The Possibilities ezine is designed so dropping the CSS degrades the ezine pleasantly to the default style of the reader. Inline styles for bolding and such can help in cases like this.

The above notes are mostly my opinions, based on my own testing of several different readers and loosely based on feedback from subscribers with various types of readers.

Now, here is the source code:

 
 

And here is a copy of the ezine the above source code produces:

 
 
ISSN 1526-9116 - Issue 330 - November 15, 2005
 
William and Mari Bontrager, Publishers
Copyright 2005 Bontrager Connection, LLC.
http://willmaster.com/possibilities/

Possibilities

You are subscribed as will@example.com
Unsubscribe information is at the bottom of the ezine.

Inside:

Creating HTML Email

 

Your subscription is sponsored by:

Prelude:

Hello William,

WillMaster.com is moving to a new server.

This means you might need to change your whitelists.

If you whitelist by IP address, the new IP address is 64.21.87.170 (the old one was 128.121.218.30)

If you whitelist by domain, there is no change. The domain is still willmaster.com

If you whitelist by email address, the "From" and "Reply-To" addresses will now be p@ instead of possibilities@ (both willmaster.com). The possibilities@ address is getting so much spam it's time to change. And now, while other things are changing, is a good time to do it.

The new information will be effective next issue.

—————

For some of you, the willmaster.com DNS change will already have taken place by the time you receive this issue. For others, it may be a few days. It depends on how fast your ISP updates their DNS information database.

The domain has several hundred scripts. And other things changed. It may be a long time before we are done with checking things.

We could use some help, if you happen to surf our way.

Should you see anything that needs fixing, please let us know. The "Contact Us" link at the bottom of every content page can be used -- if no such link is available on the page with the glitch, the home page has one.

See the "I'm Stressing About This" blog entry on the home page at http://willmaster.com/ for more info.

—————

"I'm Stressing About This"

"Form Hijacking Resources" (with free formatted copy 'n paste resource list for your web pages)

"Unique Style Sheet For Printer-Friendly Page"

"Downloading and Redirecting From the Same Link"

Those are some recent blog entries you may have missed. See http://willmaster.com/

—————

Today's article is about creating HTML email that renders well in a variety of email reading software.

Enjoy the issue, William.

Will Bontrager
"Possibilities" ezine


If the Possibilities articles are useful to you, they might be useful to your site visitors, too. See http://willmaster.com/possibilities/syndication/

—————
 

Possibility:

Creating HTML Email

Creating the contents of an HTML email is nearly identical to creating an HTML web page.

The source code of a web page might be copied and pasted into an outgoing email without modification. Yet, what looks good in one email reading program might be a mish mash of confusion in another.

The primary consideration when creating HTML email is that email reading software is less standardized than web page browsers.

Some email readers can read only plain text. This is merely mentioned. The focus of this article is creating HTML email for software that can read HTML email.

Email readers are titles like Thunderbird, Eudora, and Outlook. For the purpose of this article, web pages that let email be read with a browser are also considered to be email readers — for examples, the email services provided by http://hotmail.com/ and http://mail.yahoo.com/

It is not always possible to know ahead of time which email reader will be used at the email's destination.

Surveying every recipient is one way to obtain the information. Another is to record the information in the X-Mailer email header line with the subscription address whenever an emailed subscription is received.

Unless you can determine that most recipients will be using one type of email reader, it is prudent to design HTML email for appropriate display on the greatest number of email readers.

The easiest way to accomplish that is to use only HTML and a minimum of HTML tags. Most popular email readers understand at least some CSS.

Things that should not be used if it can be avoided:

  • JavaScript.

  • Complicated layouts.

  • Potentially hazardous HTML tags, like "script," "embed," "object," or "applet."

  • CSS positioning.

  • Forms.

If you must use any of the above, and even if you don't, send test emails to as many of the popular email readers as you can. Expect trial and error until you become familiar with what each email reader is (and is not) capable of displaying in an acceptable manner.

Images can be displayed in HTML email by linking to them the way it's done in a regular web page. Use absolute http://...URLs, though. Relative URLs will not work. Similarly, web page and download links can be incorporated.

By way of example, let's look at how the HTML version of the Possibilities ezine is constructed.

(If you are reading this article in the Possibilities ezine, view the source code to see an example, or view the page at http://willmaster.com/possibilities/EzineSourceCode.html to see the source code of the entire ezine that carried this article.)

The layout of the ezine uses a table to restrict the ezine width on wide windows. Overly long lines can be difficult to read.

An external style sheet is linked to in the head area of the HTML email. The style sheet is used mostly for font styles and weights.

At the top of the ezine is the masthead image. In case the email reader has images turned off, the name of the ezine is repeated below the masthead.

Rarely are additional images used.

The rest of the ezine is composed of heading text and paragraphs.

It's a simple layout, one that most HTML email readers can display. Even with the simple layout, the ezine looks good.

Sending the HTML Email

Many email programs can send HTML email. This is good for sending an email to an individual.

But if you'll be sending the email to a list of subscribers, you'll want good list software — like B-Mailer(TM) from http://bontragercgi.com/programs/b-mailer/

B-Mailer can send text or HTML email, your choice.

The one-click unsubscribe URL, because it can be used in both text and HTML email, needs to be constructed as a link when creating an HTML email. The link would be this format:

<a href="[[UNSUBURL] ]">click to unsubscribe</a>

To have the URL itself be the clickable text, the link would be:

<a href="[[UNSUBURL] ]">[[UNSUBURL] ]</a>

[[UNSUBURL] ] placeholders are replaced with unique one-click unsubscribe URLs when the email is sent.

The one-click confirmation URL and other placeholders are similarly replaced when the email is sent.

Many people feel that sending HTML email is better suited to their purposes than plain text. These days, with email readers that handle both formats seamlessly, many subscribers care more about content than format, so long as what they want is easily assimilated.

The essential point to keep in mind, when sending HTML email is to "Keep It Splendidly Simple".

Wait ... ... ... There's More!

See http://BontragerConnection.com/ for site owner-friendly tips and tricks and hands-on instructions for automating your web site and making it more effective.

Will Bontrager
Copyright 2005 Bontrager Connection, LLC
"Possibilities" ezine

No reprint permissions are granted, except through syndication of the current article as provided at http://willmaster.com/possibilities/syndication/


Addresses, URLs, and Subscription Maintenance:

Link to unsubscribe: http://willmaster.com/possibilities/sub/unsub.pl?933919199lwill@example.com

To subscribe: http://willmaster.com/possibilities/

Changing email address: First unsubscribe your old address, then subscribe with your new email address.

Preferences: http://willmaster.com/possibilities/MEMmod.cgi?will@example.com

Subscription Terms Of Service: http://willmaster.com/possibilities/sub/subscriptionTOS.shtml

Archives: http://willmaster.com/possibilities/archives/ (original)
http://bontragerconnection.com/ (new)

Subscribers' links: http://willmaster.com/possibilities/subscribers/

Publisher's email address: possibilities@willmaster.com

Will & Mari Bontrager, Publishers
Bontrager Connection, LLC
3213 West Main #304
Rapid City, SD 57702
USA

Copyright 2005 Bontrager Connection, LLC.
http://BontragerConnection.com/


Subscription Record:

Please Note: We do not make our mailing lists publicly accessible. Privacy is precious. We respect yours.

This personal subscription information is printed only on your copy of WillMaster Possibilities:

Name: William Bontrager
Email: will@example.com
Subscription Date: Thursday, August 5, 1999
Subscription Expires: Wednesday, August 20, 2008

To remove your subscription (to unsubscribe):
Use this link
http://willmaster.com/possibilities/sub/unsub.pl?933919199lwill@example.com