Does the website you’re building generate emails, either from a form result or as a thankyou to an end user, or a password reminder? Have you looked at the REAL, RAW text of the email in a text editor (yes an email is just a structured text file, with a set of headers, an empty line, then a body). Note, Outlook mangles emails – you can’t look at it there. You need a client like thunderbird or use webmail. In the headers, look and see what your Spam Blocker has marked as wrong with the email. Even if that doesn’t add up to being spam, its still worth dealing with, as other spam scanners may score those rules differently.
The 3 issues that I’ve noticed that are quick wins to resolve with several of the emails we’ve been generating are:
1. No real name in the from, to and other email address headers. Instead of From: noreply@mywebsite.com To: the@myrecipient.com.au you should have
From: noreply@mywebsite.com To: My Recipients Full Name
This can easily be done in .NET by using the second parameter to MailAddress
new MailAddress("noreply@mywebsite.com ", "noreply@mywebsite.com");
2. No text alternative part to a HTML email. Sure, generate a nice pretty body for the email in HTML, but ALSO attach a MIME text/plain part as multipart/alternative with pretty much the same text as the HTML but with no markup, images and any links as the http:// url in the text. Keep your text to 72 characters per line, and your links short so they don’t cross a line break. Keep the domain name of any URLs (in text and html), images (in html) etc all in the same domain, and preferably in a related domain of the From address.
See http://forums.asp.net/p/1052552/1783976.aspx for an example of sending multipart/alternative in .NET.
3. Don’t encode your HTML or text parts in BASE64 or Quoted-Printable. They should be plain old 7-bit us-ASCII. No 8 bit characters in the HTML – use HTML entities instead (i.e. use é instead of the 8-bit é character – you should be doing this anyway in all HTML).
See http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.bodyencoding.aspx – if there are 8bit (UTF8) characters in your body .NET will automatically selects a TransferEncoding of Base64. You may not even have an 8bit character but if the encoding of the string you assign to the body is UTF8 I suspect it does the same. You may need to explicitly set the BodyEncoding property to “us-ascii”. You won’t know until you look at the raw email as it gets sent over the tubes.
Bottom line, and this applies to coding as well as programming. Keep your email templates as simple as possible and always create a text version of the template. Always, always test and check the emails outside Outlook where you can see the raw email (as well as inside Outlook to make sure they look ok).