How to prevent spammers from using your domain

Creative Commons -

Most people don’t like spam. It clutters up the inbox with unnecessary junk, and takes away the focus from legitimate mails.

If you have your own domain like me, it gets even worse. Spammers have claimed to send mail from This is visible when the “From”-field looks something like “”, but the mail is not sent from me or are a legitimate email adress in my domain. A mail contain a header that provides information about the mail itself, where the mail was sent from, date etc. This is how a mail header look like:

Received: from [] by id <5416176-86323>; Sun, 16 Nov 2003 13:38:22 -0600
Message-ID: <o7-89089$t–2-370–h6b1@y07l72.olpvl>
From: “Reinaldo Gilliam” <>
Reply-To: “Reinaldo Gilliam” <>
Subject: How would you like 2 Million Sites linking to your ad ?
Date: Sun, 16 Nov 2003 13:38:22 GMT
X-Mailer: Internet Mail Service (5.5.2650.21)
MIME-Version: 1.0
Content-Type: multipart/alternative;
X-Priority: 3
X-MSMail-Priority: Normal

Spammers put a fictitious email address in the From-field which is useless if we want to find the real source of the spam. When pressing “reply” on a mail, the Reply-To field is used and is the email address of the spammer.

There is a way to prevent spammers from using your domain. It’s called SPF records and are set in the DNS. The DNS settings are set by your web host provider or you can do it yourself if your web hosting company provide that capability. I will not explain what DNS records are and the technical details behind it. This posting is more to tell you about what it is, and how it works.

Let’s take a look at the current DNS records of

The values from a DNS lookup on

I’m using as my hosting service (pretty happy with their support and service by the way). The MX record tells where the mail server I use is located. When a mail is sent to helene @ klungvik . com, the mail server does a DNS lookup on and locates the MX record.  All mail I receive is therefore sent to, before ending up in my mailbox.

So how does the SPF record work and how can that prevent spammers from using my domain?

SPF records allow the domain owner to specify what servers all mail from it’s domain will originate from. So if a mail is not sent from one of the specified domains, it will be marked as spam. The SPF record for are located in the TXT record and looks like this: “v=spf1 a mx ~all”.

An excellent description of SPF-records

a = address records that will match the senders address.
mx = mail server
~all = the qualifier, ~all means that mail sent from other servers will be accepted, but be marked (which usually means that the receiver will get the mail, but the mail will end up in the junk/spam folder).

All valid mail from will therefore be sent from any of these IP addresses/servers: (which is, and

So how does the mail server use the SPF-record?

The mail server receives a mail. It takes a look at the “Received”-field which contains an IP-address: The mail server does a DNS lookup on and checks if the ip-address corresponds to any of the servers specified in the SPF-record for Since is not listed among the valid mail servers, it will be marked as spam.

There is some pitfalls to be aware of when specifying SPF-record for a domain:

1. You have to be conscious of where you send mail from.  You can’t send mail from any other servers than specified in the SPF-record, or it will be marked as spam (and either not be received, or end up in a spam folder).

2. Forwarding of received mail can result in the mail be marked as spam.

The spammers stay shy of domains that have specified SPF-records, since they know that any mail will automatically be marked as spam. It also ensures that legitimate mails (like those I send), will be received.

About Haridasi

integrity - the state of being whole, entire, or undiminished.
This entry was posted in Technology, English, System Administration and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *