One common problem with sending HTML emails is finding something to do the actual sending with. I’ve got the HTML, but how do I actually send it to the distribution list without my email client turning it to garbage in the process?
Many organizations already have a distribution mechanism they trust that avoids this problem for emails that follow your typical format, but many times these do not allow you to send an unaltered html file. The system that allows for “easy editing” of the content leaves you less control over the HTML. If you have a time sensitive broadcast, or you just don’t want to spend an hour futzing with your email broadcast service provider, you might look for a quicker solution. This is not rocket science after all, we just want to take HTML that is already complete and tell the computer that it’s an email and it should go to this list of people.
To accomplish this without the “help” of a service provider, a few times I’ve used the trick of just sending the contents of an HTML file to the sendmail command on a *NIX or Mac OS X machine. As long as sendmail is configured properly (which it usually is if you have command line access to a shared-hosting web server), you can use sendmail’s “-t” option to tell sendmail to get the email’s recipients information from the header information in the file. Then you just need to add a few lines of header information to your HTML file so that it looks like this:
Errors: errors@derekgulbranson.com
From: Derek Gulbranson <derek @derekgulbranson.com>
To: Test Recipient < derek@derekgulbranson.com >
Subject: Sending Via Sendmail
MIME-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 8bit
</derek>
You’ll want to be sure that the domain in the From: email address resolves to the same IP address as the machine that is doing the actual sending or the email may get a high spam rating, be blocked by ISP’s, or possibly cause that server to be “black-listed”. The From: name is not checked against anything and can be whatever you want.
You may want to do some research in the the multipart/alternative and other available types via the RFC’s if you want to include a plain text version.
I would expect this also would allow you to safely send emails using alternate content types like UTF-8, but I have not done much testing with this.