Good practices for sending emails from your web server

Posted on April 16, 2012
by

On Forexagone.com, we like to do everything ourselves, meaning we don’t like to use many third-party services to handle our work, so we are sure that everything is tailored to our needs, well integrated and working all together. For sending our emails, we decided to do it ourselves as well and not use a service like mailchimp or such. I learned much throughout my research and work on implementing the necessary technical stuff, so I thought it’s a good idea to write my learning on my blog, so it will be like a reminder for me, and it could help others who want to do the same.

Nota Bene: this post is not about the email marketing strategy itself, it is only about the technical setup for sending emails from your server and doing it right.

Like me, you have your own reasons for sending emails from your own server and not using a third-party service. If you decide to do so and go on reading this article, you would like to know the benefits of implementing the things I describe. There are many benefits.

  • it lowers the chances that your emails land in the spambox of your subscribers (heck it is important!)
  • it makes you comply with the legislation (can vary from the country but better too much than not enough)
  • it makes your subscribers happy
  • it shows a professional attitude

My list of good practices might not be complete and I excuse in advance, but they are already pretty important to carry out.

1° Add an SPF record to your DNS configuration

Sender Policy Framework (or SPF) is a system to validate the authenticity of the sender of an email, and make sure that the sender has not spoofed an email address in relation to your domain name. It is important that you do so because email services like Gmail and Hotmail use that factor in their decision to make your email land in the spambox or not (it is not the only factor though).

To implement SPF, you just have to add a record to your DNS configuration. The line depends largely on how you manage emails… Will you send emails from many servers, will you send and receive emails with this domain from another email service as well, and such… I will give you an example for the two most common cases.

You send emails for that domain name only from your web server. The SPF record will be:
v=spf1 a ~all

You send emails fro that domain name from your web server and also from your email service. The SPF record will be:
v=spf1 a mx ~all

Important: note that you can have only one SPF record by domain name. If you need to state that several servers will send emails from your domain, you need to list all of them in only one record.

Anyways, the simplest for you is to use Microsoft’s wizard to generate the SPF record for you. Here is my DNS configuration for my domain name cyrilmazur.com for example, for which I send emails from my web server and also from my email service (which is defined in the MX record, redirect.ovh.net):

2° Make a bounce email address

When an email doesn’t reach its destination, we say it bounces. Email servers and relays are very persistent, they will usually try and try many times to deliver your emails, but it might happen that the email never reaches its destination. Reasons for that can be that the email address is not valid at all, or maybe the inbox is full or even the email service of your recipient is temporarily down… Nevertheless, when an email cannot be delivered, it is automatically sent back to the Return-Path address. Note that this address might be different from the “From” address, and actually I encourage you to at least create an email address specially for receiving bounces (let’s say, bounce@yourdomain.com). Here are the headers of an email we usually send from Forexagone for example:


You can see that the return path (bounce@yourdomain.com) is different from the email address of the sender (info@yourdomain.com). And I believe it’s better to do that way. Note that some old email servers will not consider the return-path address and bounce backs emails to the sender’s address, it might happen in some rare cases…

What to do when you receive these bounced emails? Well it depends on the case… You will usually read the reason for the bounce, and if this is a permanent error, then you should remove that address from your mailing list. Why? Because it’s also a factor that email services are using to determine whether you will land in the spambox or not. Moreover, knowing exactly who is receiving your emails or not is a valuable information for your email marketing strategy.

If you want to automatise the process of removing bounced emails’ recipients from your database, you might want to check out VERP (that I also implemented on Forexagone.com, that’s why you can see such a strange address for the return-path header).

3° Configure a reverse DNS for your server

You know about DNS, right? You have a domain name, and it matches with an IP address. Example you type in “www.forexagone.com” in the address bar of your browser, and it is automatically translated into the IP address 91.121.145.102 and you don’t even have to think about it. This is DNS. Reverse DNS is the opposite, it matches an IP address with a domain name, to ensure that this IP address is used by this domain name only.

This is one of the other factors that is used by email services to make you go to the spambox if you don’t respect it. It depends on the service, but note that AOL for example will reject any email that is coming from a server that doesn’t have a reverse DNS record.

You can test if your domain is well configured with AOL’s Reverse DNS check tool. To configure a reverse DNS for your server, ask your hosting company.

4° Sign up to Hotmail’s Junk Email Reporting Program

By signing up to that program, you know in real time if a Hotmail user is flagging your emails as “spam”. That gives you a good insight on what’s going on and why some people don’t receive your emails. If a subscriber is flagging your email as “spam” you should stop sending emails to them. Once again, that will lower the chances that your emails land in the spambox, and that proves to Hotmail (and to your subscribers) that you are a honest and professional business. Registration can be done here: JERP enrolment.

The same way, you should also sign up for Hotmail’s Smart Network Data Services, which will give you insights and stats about your emails received by Hotmail’s users.

5° Add a link to unsubscribe from your mailing list in EVERY EMAIL YOU SEND

Why it is important to do so? Because then your subscribers will be clicking that link to kindly tell you to stop sending them emails … instead of clicking the “this email is a spam” button of their web mail service, which would be way more harmful to you. Anyways, if someone doesn’t want to get your emails anymore, whether you give him a clean way to unsubscribe or not will not change a thing.

Sometimes people don’t care about that kind attention to have an “unsubscribe link” and still click the spam button. Unfortunately you can’t avoid that… but with that link, you can decrease the number.

It’s important also that you make it easy to unsubscribe. Don’t ask your subscriber to log on his member area and then configure his email preferences. No, instead make it easy to do, in just one click, no more.

6° Create an abuse@ and postmaster@ addresses

These two addresses are like a standard requirement for several services. It’s standard that postmaster@yourdomain.com is the “standard” way to contact the owner of a website. It’s even a requirement to have a functional postmaster@yourdomain.fr address if you want to register a .fr domain name for example…

abuse@yourdomain.com is a standard address used for complaints. Systems sometimes send mails automatically to that address when they have a spam complaint to make or such…

Anyways, you don’t have to create real inboxes for those, you can well simply create aliases and forward these mails to your personal inbox, it doesn’t really matter, but you must be able to receive emails sent to these two addresses.

 

I believe my list is far from being complete, but those are important tasks that you need to carry out at least to maximise your chances to avoir the spambox and increase your deliverability rate. Beyond the scope of the technical setup, of course, there is also a big part of the work which is about the strategy itself, writing emails that your subscribers really find interesting, and such…

I hope it helps for the web developers who start managing emails on their web server. If you have ideas of other good practices to add to my list, please comment in the section below 🙂 Thank you!

About the author

Cyril Mazur is a serial web entrepreneur with experience in various fields: online dating, forex & finance, blogging, online advertising... who enjoys building things that people like to use.

7 comments

  1. David
    on February 28, 2013
    Very helpful - I'm new to this - do you just use the php mail function, then? Or something else?

    Cheers
  2. Cyril
    on March 1, 2013
    Hey David, actually I'm using the PHP Mailer class.
  3. Raj
    on October 7, 2013
    Hi Cyril,
    I m developing an ASP.NET(with sql server) application.
    I need to send emails to those users who have been subscribed for Newsletter.
    My requirement is to sent emails from web server( in my case Windows Hosting from Godaddy) at specific intervals may be weekly or monthly.
    Please help me by giving hint or URL.

    Thanks
  4. Cyril
    on October 7, 2013
    Hi Raj, sorry but all the good practices i give on this page are technology agnostic, they are valid for ASP.NET web server as well as a LAMP server or whatever.

    For the ASP.NET implementation of sending emails, you should look into the doc, I am not an ASP.NET coder, sorry. Good luck!
  5. Ross Armstrong
    on October 26, 2013
    Your site is quite educational for newbies like me, thanks for your efforts.

    I am building a simple site for a seniors club, nothing fancy but I'm having difficulty with SPF failures and do not understand enough about what is required in DNS records.

    The web host is mediatemple.com which was just bought by GoDaddy. We subscribe via a reseller who is not helpful.
    The TXT record is "v=spf1 include:spf.mail01.mtsvc.net -all" (used mxlookup to find it). The problem is that all emails from all email accounts on our site fail SPF.
    The most informative error message came from gmail which said:
    "mx.google.com; spf=hardfail (google.com: domain of webmaster@shorespa.ca does not designate 72.10.34.60 as permitted sender) smtp.mail=webmaster@shorespa.ca".
    I have headers from other messages it required.
    Can you give me some advice as to what to add to the DNS record to correct this.
    Many thanks for any assistance you can provide.
    Cheers.
  6. Cyril
    on November 28, 2013
    Hi Ross, sorry for my late reply, it's been a while I didn't check my comments...

    IMO you lack of an "A" in your SPF record (for saying that your A record, in this case shorespa.ca -> 72.10.34.60, is allowed to send mails).

    Try the following string: "v=spf1 a include:spf.mail01.mtsvc.net -all", does it solve the problem?

Leave a Reply