Author Archive

Coding email templates

Saturday, November 22nd, 2008

I’ve written a couple email engines in my day – one in PHP and one in ASP – to integrate and automate businesses with email marketing.  Work to be proud of, indeed. Invariably after the engine part is done – or maybe you’re using an established service* for the engine part – there needs to be some content, some email design.

*Examples of consumer email marketing services (”engines”) using email templates and data merging:

Templates are for branding

HTML templates need to be made so the emails that are received are branded – at least with a logo and company colors.  This is not possible with a plain text email of course.

Merging process

The engine will take the templates and merge in some variables like “first name”, “email to”, “email from”, etc – a basic find-and-replace loop.  The HTML template will contain placeholders for each variable – strings like “{#EMAIL_TO#}” – and the loop will replace those with values from the database, then send the post-merged email to that person in the mailing list.

Email formats

There are many ways an email can be formatted such as “quoted-printable”, “text/plain”, and embedded images, but my focus is on “text/html” with linked images.  Here is a handy site that can convert static HTML into quoted-printable format, and back.

Images

The images will be stored on a server and referenced like any other web page would reference images.

Privacy and missing images

Some email viewers like Gmail tend to hide images that link back to a server, and the user has to click a “display images” link to see the email as it was intended.  This is a privacy feature because images that link back to the server provide the sender with a method for tracking who opens the email.  The log can be parsed to see who requested the image when the email was viewed.

We need to make the design look good even if all the images are missing.

alt attribute

For this reason, be sure to fill your image tags with good descriptive “alt” values so those users still know what they’re not seeing.  Putting “please display images”  in the “alt” attribute is a consideration, but might also be a flag to the program that the message is spam.

Tables

Today web designers use style sheets instead of tables for positioning content.  CSS-heavy, un-tabled code may be a good idea for modern web sites, but not for HTML email templates.  Email templates rely primarily on tables for positioning content, making columns, aligning text, etc.  This is simply because the email could be viewed in any number of applications, with a high likelihood of poor CSS support, even in modern email clients such as Outlook 2007 (whose rendering engine is Word, of all things).  Tables are “old school” web design, and so are email templates.  Being a CSS guy, I just have to suck up that reality.

Put CSS in style attribute

This isn’t to say that one should abandon CSS in email templating altogether.  In fact, feel free to use the “style” attribute – just back it up with the non-CSS way too, as insurance.

If the cell needs a background, use “style=background:url(some image path)” in addition to “background=(some image path)”.  If the font needs a color, use “style=color:red” in addition to “<font color=#ff0000>”.

Go attribute-crazy

The more attributes each table cell has, the better.  Don’t forget attributes such as “height”, “width”, “background”, “bgcolor”, “align”, “valign” and even CSS’s “style”.  You’ll thank yourself when testing in even the latest browsers and email clients.

Always use the “align” attribute in cells with text.  I can’t tell you the numbers of times I’ve seen Internet Explorer “center” text that “left-aligns” in Firefox. Setting “<td align=left..” fixes this.

Stay aware of the design affects of merging in variable data that could reflow text and images.  When columns are growing and shrinking with variable content, and you want the content to “top-align,” use “<td valign=top..”.  Otherwise there tends to be rarely-desirable vertical centering.

Variable images

If your variable images are variable sizes, heaven help you.  If necessary resample all the variable images – perhaps with ImageMagick – to give them the same widths or heights – whichever dimension flows best in your design.  Whatever table cell is containing your image should still have the height and width set.

spacer.gif

A spacer.gif is a 1×1 transparent GIF that can be resized to enforce the size of an empty table cell.

Remember those?  You’ll wanna pull those out from the back of the toolbox to help pad your tables.  Tables + spacer.gif is the “old way” but it’s the “right way” when it comes to making email templates.

If I have an email with 2 columns and padding in between, I will use a 3 column table with all cells’ widths, aligns, valigns set, and put a spacer.gif in the center “padding cell” that is the same width as the padding should be.  The height of the spacer.gif can remain 1px.

Spanning

If you find yourself using “colspan” or “rowspan”, don’t.  Instead, nest tables.  It’s sounds like such a naughty thing to say, but that’s the most dependable way to go.  Go nested-table crazy! We can’t give the cell dimensions any leeway.  Spanning cells tends to produce more random cell dimensions than the predictibility of nested tables.

Table setup example

Here’s a good set up for a centered, 650px-wide table.

<table cellspacing=”0″ cellpadding=”0″ border=”0″ align=”center” width=”650″>

“cellspacing”, “cellpadding” and “border” need to be set. Assume nothing about any dimension.  Be explicit everywhere.

Testing

Don’t forget to test in multiple browsers, and multiple email clients. This is where we see how necessary all the excessive table markup was.

Here’s a few email clients to consider:

  • Outlook 2007
  • Older Outlooks
  • Gmail
  • Yahoo Mail
  • Apple Mail
  • Hotmail

Just because the email client is web-based doesn’t mean it is just as CSS-compatible as a you’d expect.  Sometimes the CSS is rewritten to prevent style conflicts with the web page it is presented in.  We would hope that the rewriting will not be harmful to your CSS, but I wouldn’t bet on it.  Best to take the hybrid route so we won’t have to worry about it.

Conclusion

Email template design is an aging art with the advent of Web 2.0 social marketing tools, but it still reaches the most people wherever they may be online.  Deploying age old web design techniques is still the best way to code an email template so that it looks the same in most people’s email clients.

Timeline of stuff I am into

Wednesday, October 29th, 2008

I dream up, design, build, deploy and maintain web-based tools and web sites using these tools. So much fun in so little time.

Timeline of stuff I am into.

Quick Links: Social Networking | Web Programming | Web Design | Art

Ranking, Blog Code, Custom Search, Firefox Add Ons

Saturday, September 20th, 2008

Improving your site’s Alexa Rank and Google PageRank, showing code in your blog posts with syntax highlighting and line numbers, creating a custom Google search box for your website, surviving and thriving in Google Reader using PostRank, and exploring Firefox addons for web developers including GreaseMonkey and Web Developer.

Source code in blog posts:

Ranking:

Google Custom Search

Toolbars:

Firefox Add Ons:

jQuery Experimenting:

Like a podcast? Tell them!

Saturday, September 13th, 2008

So, I subscribe and listen to 49 podcasts.  (Up until I counted just now, I was saying 30.)  Some release content more frequently than others.  It’s good background for commuting, playing XBox, working out (I’ve heard), and, depending on concentration requirements, working.

Podcasting has a small audience, although growing, and is usually a labor of love.  Unfortunate.  The public is missing out big time!  Hardly any commercials; solid content on any topic.  Radio, in stark contrast, has too many commercials, has dumbed down, generic content I could give a crap about, and the sound quality sucks (if it even comes in at all).

Sometimes the only reward for podcasters is feedback and occasional donations. Unfortunately I should interact more. Everyone might benefit.

Today I was five podcasts deep when, all of the sudden, I realized I was hearing someone reading what I had submitted.  It was a comment I had sent in on this episode.  1 minute of fame!  Haha.  Very cool.  My comment was basically “good show”.  (A better comment would have included suggestions, but alas, I got nothin.)

The podcast is about being healthy.  Since I’m usually buried in tech news, as my waistline can attest, the show increases my health mind share.  That increases my chances of making healthy choices.  Health isn’t my passion, but the content is worthwhile.  You should check it out.

Like a podcast? Tell them!

Listen to Talli and David’s “Being Healthy for Busy People” podcast.

    Code formatting in blog posts

    Friday, September 5th, 2008

    Do you like posting source code samples on your blog?

    I wasn’t sure how.  I just surrounded it with “<pre>” tags. That works in the basic sense. What about the syntax highlighting and line numbers?

    A search of the WordPress FAQ’s revealed this how-to on posting code.

    Basically it looks like this.  Just tell it what language you’re using.

    It also revealed Google’s syntax highlighter for when Javascript libraries are doable.

    Pretty simple. Thanks Google and Wordpress.

    Flames and Avatars

    Friday, September 5th, 2008

    “What’s up with the flames in your header?”

    Beats me.  Every time I mix Beer + Internet + Photoshop, something on screen catches fire.  Listening to heavy metal probably didn’t help either.

    “Hey, you have one of those avatars I’m seeing everywhere.  How can I make one?”

    http://www.faceyourmanga.com/

    If you make your own avatar, post a comment with a link to it here.  I’d love to check it out.

    Van Turtle Blog Design - Sep 2008

    Van Turtle Blog Design - Sep 2008

    A trained technician working in the USA will be right with you

    Saturday, August 30th, 2008

    This is not an ad.  I’m not getting paid.

    Bluehost.com – domain hosting – PHP Hosting

    Why the switch? Speed. Previous host was unbearably slow, and shouldn’t even be in business any more with performance that bad.  They’ve been a major web provider since the 90’s, and I expected more. Even their own homepage is slow.  Pitiful.

    Bluehost will be my 5th hosting service, and so far I am 100% impressed with no red flags.

    Server performance is excellent.  After I signed up, a human from the US called me to verify that I signed up.  She asked questions, I said yes, yes, yes and thank you.  Nice.

    Keep up the good work and I’ll refer the bajebus out of you.

    I saved $2 a month by going here first, then clicking the Bluehost link.

    This blog is hosted by wordpress.com.  I am using Bluehost for podturtle.com.

    Hooking Javascript Validation to an HTML Form

    Sunday, August 24th, 2008

    HTML forms, which collect data from users, usually have more going on under the hood than meets the eye. They need to check the inputs to make sure they’re formatted correctly for the database. The server needs to validate the input, but validating input at the client makes for a better user experience. Let’s look at the what, why, and how of validating HTML forms on the client-side.

    DavidVanVickle.com Javascript Validation Demo and Tutorial

    webcheatsheet.com Validation Functions

    Updating and Networking with a Virtualized OS

    Friday, August 22nd, 2008

    I have Mac Leopard running Parallels 3 running Windows XP, using wired ethernet to network, not wireless.  It rocks, even with all my Adobe CS3 work on both platforms at once.  Don’t let the following comments deter you from a similar configuration.  It’s not difficult.

    Two biggest tips:

    1. Make sure to follow the instructions when updating.
    2. Always backup first, especially now that you’re dealing with *2* OS’s!

    Okay now for glimpse into my situation, stupidity included.  If this helps anyone, cool.

    Because I started toggling the network settings on the Parallels Mac side around the time of my update to Parallels v3 build 5608, sometimes Windows couldn’t get on the web.  I switched between “en0″, “en1″, “host-only networking”, and “shared networking”. Eventually I took whatever brought the Internet back.

    That kinda worked, but then my FTP started having trouble.  I could connect to the FTP server, but when I tried to GET or PUT files, I got the “Illegal PORT command” error from the FTP client.  This was the big mystery.  “Illegal PORT command”?!  Huh?  I latched on to the “port” part and even tried dropping my firewalls.  That surely did more harm than good.

    Ultimately the correct settings (for me) were “bridged ethernet” “default adapter” (not “shared networking”).  Now it ALL WORKS!  Yay!  (Your mileage may vary. See Parallels for details.)

    Now it all works again and I promise not to touch anything until the next update.

    Networking without a map is anything but simple, especially with all this virtual sharing bridging NAT stuff mixed in.  I’d say Parallels does a great job of making it as easy as possible and their help pages are pretty thorough (although a forum might be cool).

    Here’s a shot of where I set “bridged ethernet”.

    If you have questions, don’t ask me. ;)

    Results of My Personality Test

    Sunday, August 3rd, 2008

    “Just the facts, ma’am”

    HumanMetrics.com – Jung Typology Test™ – Take it here

    Your Type is: ISTJ
    Introverted Sensing Thinking Judging
    89 12 50 11
    Strength of the preferences %

    See the complete report at my site.