Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
How do you write a HTML email
Hazzie
Does anyone know what you need to be able to write a html email? What headers are needed is their specific bits of code are needed any advice or tips? I am presuming much like 1 browser is different from another 1 email client renders a html email slightly differently to another one.
Is there a standard?
Is there a specific way in which you need to write it, i.e. in outlooks case do you need to have it in HTML format as your writing it or can you write your email in plain text mode and specify somehow that it should be rendered on the receivers screen as html email?
Any tips or web sites would be helpful.
Cheers,
hazzie.
Hazzie
TS 5.5.2 on NT.
Find more posts tagged with
Comments
rollo
In its most basic form, an HTML email can be created like this:
From:
email@blah.com
Reply-To:
email@blah.com
To:
email@blah.com
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Date: Thu, 29 May 2003 11:45:51 -0700 (PDT)
Subject: Subject
<html>
blah blah
</html>
That'll do it for most email clients, in my experience. But if you're still using a text-based client like Pine or Elm or whatever, you just get a screen full of code. A more friendly way to deal with it is to supply an alternate text-only version for those who cannot render HTML. A MIME-savvy client will pick the most appropriate version, whilst the rest will at least display something more friendly than raw HTML:
From:
email@blah.com
Reply-To:
email@blah.com
To:
otheremail@blah.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="main_1234567890"
Sender:
email@blah.com
Date: Thu, 29 May 2003 11:45:51 -0700 (PDT)
Subject: This is a subject line
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--main_1234567890
Content-Type: multipart/alternative;
boundary="inner_1234567890"
--inner_1234567890
Content-Type: text/plain; charset=utf-8
Plain text version of email
--inner_1234567890
Content-Type: text/html; charset=utf-8
<html>
....
HTML version of email
....
</html>
--inner_1234567890--
--main_1234567890--
The boundaries can be anything, but usually they're derived from the time of creation (I always use seconds since the Epoch, mainly cos that's how Perl deals internally with time). The date header is kinda tricky - I match the format they use in RFC822, but I've seen other formats used as well. I've tested the emails as described above in Outlook 2000, AOL and a couple of web-based email services, and they display as expected.
Incidentally, I have tried to send HTML email directly from Outlook without success - there does not seem to be any way of doing it. The 'quick and dirty' way is to telnet to port 25 of your SMTP server and paste the full body of the email, but it's more flexible in the long run to use Perl and one of its modules. I use Net:
MTP myself.
Standards.. well, the standard for internet email is the aforementioned RFC822. MIME is set out in RFC1521 and updated in 1590 and 2045-2049. They're very thorough. Check out
http://www.faqs.org/rfcs/
for all the RFCs you could ever want.
If you have any questions or need clarification, please ask. I know more than is healthy about this stuff...