If you’re using PHP you want PHPMailer. If you’re using something else there’s probably an equivalent library (Google is your friend). However, regardless of how you do it you should always consider the impact of your email activities on your users. Unwanted email is one of the biggest problems on the Internet today and the more you can do to present your website as a responsible sender of email the better.
There are essentially two types of email that you might send out to the users of your website: operational and non-operational. The purpose and content of the two differ greatly and it’s important to understand the purpose of each to ensure your users understand why they’re getting them and what action (if any) they need to take when they do.
The term operational emails refers to emails that directly relate to the service you are providing the user. For example this would include welcome messages, order acknowledgements and reminders that you may send to users in response to their actions or other events.
Successful operational emails are the ones that keep it simple. You’re sending them because they provide value for the user, so avoid the temptation to load them up with marketing information.
You're sending this email because you need to tell the user something, so tell them. If you really need to add other stuff like marketing messages be sure to do it low key and after the primary content. The worst thing that can happen with your operational emails is that your users start ignoring them because the signal-to-noise ratio is too low.
Ask anyone in sales or marketing and they'll tell you that to engage people you need flashy graphics and pleasing colours, and at times they're right. However, when it comes to operational emails your users are already users - they're already engaged. Plain text is your best option. You can get the point across quickly, the message is less likely to be marked as spam and users won't get any security warnings when they open it.
One thing you do need to ensure when using plain text is that your links are short to avoid them wrapping and becoming unclickable.
Note that not using HTML for these emails is probably more of a personal preference, but in my opinion while HTML email is a necessary evil for sales and marketing messages it has no place in operational emails.
Promotional emails can be a very effective way of reminding your users that you’re there. I’m sure I have accounts on many websites I never visit and that haven’t even crossed my mind lately, but it’s likely if I received an occasional email from them I’d go visit them. I may just go back to delete my account, but surely that’s better than account rot. On the other hand it may remind me why I signed up in the first place and I could become an active user again.
Emails can also be a great medium through which to inform your users of new features on your site, or long-standing features that aren’t getting used. And don’t forget that they also provide the opportunity to push the features of your site that make you money.
Evil reasons aside (because we all know sales and marketing people are an evil bunch), regular contact with your users is more likely to engage them with your website. Nothing you do on the site itself can have the same effect, but you have to do it right to prevent getting bitten by consequences.
The keys to success with sales and marketing emails differ greatly depending on the subject and audience.
While less pointed than operational emails promotional emails still carry a message to your users and it's important that they get it. If you look at an email you want to send and you can't immediately see what it's telling you chances are it will be ignored by a fair proportion of recipients. Time is precious and people are rarely willing to give emails longer than a few seconds to assert their importance.
You probably realise that by using HTML you can make your email more engaging, but it's all too easy to ignore the realities of the security-concious email clients that are out there. Here are some pointers to ensuring maximum compatibility...
More important (from a potential problems point of view) than the content of the emails you send is the process and procedures you use to actually send them. Most of this should sound like common sense but I think it’s important to state the obvious. The public view of commercial email, whether unsolicited or not is well-known, so unless you want to give your website a bad reputation you need to take care to do it properly.
Track your recipient list carefully. If someone tells you they don’t want your email, don’t send them email. There is no commercial value in sending email to someone who doesn’t want it, but the potential damage it can cause is extensive.
You’ll already know that you need to provide unsubscribe instructions in each email you send. For operational emails it may be as simple as “you have an account and to use it you need to get these emails”. For promotional emails you need to provide a way for people to unsubscribe from them but continue to receive operational emails.
When someone does unsubscribe, honour it. In my opinion it’s a good idea to keep a separate list of addresses that have unsubscribed as well as noting it against the user on your website. Whenever you send an email you should check to see if the recipient is in that separate unsubscribed list first.
Track these too. Email can bounce for a variety of reasons. It could be that the address really doesn’t exist, or it could be because the mailbox is full. Either way you need to have a procedure in place to deal with addresses that bounce.
Given that not all bounces mean the address is not valid it’s a good idea to have a bounce threshold. Record bounces and when you get more than 1 (or more than 2 if you want to be more tolerant) for a given address mark them as bounced and stop sending email to it. This will prevent your mail server from having to do more work than it needs to.
I’ve heard several people suggest that it’s a good idea to periodically flush bounced addresses. The argument centres around the possibility that you might mark perfectly valid addresses as bounced in fairly rare circumstances. The idea is that you unmark bounced addresses after some random period of time, thereby getting back any that were incorrectly marked as bounced. Personally I don’t think it’s worth it, but if your bounce rate is low it can’t hurt. Just be sure not to apply the same logic to unsubscribed addresses!
Well-behaved emails are those that have proper well-formed headers. The following list highlights the really important ones…
A carefully crafted envelope sender is the best way to identify bounces when they come in. Take the following address...
Set up an alias called bounce that passes the email to a script. That script then does the following...
Technically you can probably remove the need for the list name and message ID because if an address bounces for one list it's no different to it bouncing from another list. The same goes for the message ID. I use this to record events against a given message, but that's only for metrics - it serves no functional purpose.
If you're sending HTML be sure to send a plain text alternative along with it. It doesn't need to be the same content, it can be as simple as...
This email is in HTML format which your email client is not displaying. To view this email click on this link.</pre>
Keep the URL as short as possible to avoid wrapping. Make sure you also include the unsubscribe instructions in the plain text content.</li> </ul>