TABLE OF CONTENTS › Creating an HTML Email Template
Another type of template is for a “multi-part MIME email” — these are special emails that contain within themselves two versions, a text version and an html version. The email program of your subscriber decides which to display based on its own capabilities (and your subscriber’s preferences).
These emails are not much more difficult to send than standard text emails, with the help of the <txp:bab_pm_mime /> custom tag.
Here’s the simplest example:
[placeholder for the “text warning”]
<txp:bab_pm_mime type="text" />
[placeholder for the text version]
<txp:bab_pm_mime type="html" />
[placeholder for the HTML version]
<txp:bab_pm_mime type="end" />
Notice how the <txp:bab_pm_mime type="text" /> tag precedes the text version, the <txp:bab_pm_mime type="html" /> tag precedes the html version, and then the <txp:bab_pm_mime type="end" /> tag ends the email. Also notice the “mime warning,” which precedes even the <txp:bab_pm_mime type="text" /> tag — this is text that will display if the subscriber’s email program can’t read multi-part MIME emails.
So, you are going to want to replace [placeholder for the text version]with the text version, and [placeholder for the HTML version] with the HTML version (I also suggest replacing [placeholder for the "text warning"] with the text version). How do you do that?
You’ll use the Textpattern tags to pull different versions of the email into your newsletter template. Something like this would work:
<txp:excerpt />
<txp:bab_pm_mime type="text" />
<txp:excerpt />
<txp:bab_pm_mime type="html" />
<txp:body />
<txp:bab_pm_mime type="end" />
Now to get more complicated, say you want to customize your newsletters a little bit. Say, add your subscriber’s name. Something like this:
<txp:bab_pm_data display="subscriberName" />,
<txp:excerpt />
<txp:bab_pm_mime type="text" />
<txp:bab_pm_data display="subscriberName" />,
<txp:excerpt />
<txp:bab_pm_mime type="html" />
<p><txp:bab_pm_data display="subscriberName" />,</p>
<txp:body />
<txp:bab_pm_mime type="end" />
<p> tags, because it’s HTML — without the <p></p> tags, everything would run together.But our example is annoying — for each newsletter, you’ll have to type twice (once in the Body field, and once in the Excerpt field). Postmaster makes it easy to use the Body field in both places. Do it like this:
<txp:bab_pm_data display="subscriberName" />,
<txp:bab_pm_data display="Body" strip_html="yes" />
<txp:bab_pm_mime type="text" />
<txp:bab_pm_data display="subscriberName" />,
<txp:bab_pm_data display="Body" strip_html="yes" />
<txp:bab_pm_mime type="html" />
<p><txp:bab_pm_data display="subscriberName" />,</p>
<txp:body />
<txp:bab_pm_mime type="end" />