What Email Headers Can Tell You About the Origin of Spam

Middle Eastern man using laptop
Hill Street Studios/Blend Images/Getty Images

Spam will end when it is no longer profitable. Spammers will see their profits tumble if nobody buys from them (because you don't even see the junk emails). This is the easiest way to fight spam, and certainly one of the best.

Complaining About Spam

But you can affect the expenses side of a spammer's balance sheet, too. If you complain to the spammer's Internet Service Provider (ISP), they will lose their connection and maybe have to pay a fine (depending on the ISP's acceptable usage policy).

Since spammers know and fear such reports, they try to hide. That's why finding the right ISP is not always easy. Fortunately, there are tools like SpamCop that make reporting spam correctly to the right address easy.

Determining the Source of Spam

How does SpamCop find the right ISP to complain to? It takes a close look at the spam message's header lines. These headers contain information about the path an email took.

SpamCop follows the path until the point where the email was sent from. From this point, also know as an IP address, it can derive the spammer's ISP and send the report to this ISP's abuse department.

Let's take a closer look at how this works.

Email: Header and Body

Every email message consists of two parts, the body and the header. The header can be thought of as the envelope of the message, containing the address of the sender, the recipient, the subject and other information.

The body contains the actual text and the attachments.

Some header information usually displayed by your email program includes:

  • From: - The sender's name and email address.
  • To: - The recipient's name and email address.
  • Date: - The date when the message was sent.
  • Subject: - The subject line.

Header Forging

The actual delivery of emails does not depend on any of these headers, they are just convenience.

Usually, the From: line, for example, will be set to the sender's address. This makes sure you know who the message is from and can reply easily.

Spammers want to make sure you cannot reply easily, and certainly don't want you to know who they are. That's why they insert fictitious email addresses in the From: lines of their junk messages.

Received: Lines

So the From: line is useless if we want to determine the real source of an email. Fortunately, we need not rely on it. The headers of every email message also contains Received: lines.

These are not usually displayed by email programs, but they can be very helpful in tracing spam

Parsing Received: Header Lines

Just like a postal letter will go through a number of post offices on its way from sender to recipient, an email message is processed and forwarded by several mail servers.

Imagine every post office putting a special stamp on each letter. The stamp would say exactly when the letter was received, where it came from and where it was forwarded to by the post office. If you got the letter, you could determine the exact path taken by the letter.

This is exactly what happens with email.

Received: Lines for Tracing

As a mail server processes a message, it adds a special line, the Received: line to the message's header.

The Received: line contains, most interestingly,

The Received: line is always inserted at the top of the message headers. If we want to reconstruct an email's journey from sender to recipient we also start at the topmost Received: line (why we do this will become apparent in a moment) and walk our way down until we have arrived at the last one, which is where the email originated.

Received: Line Forging

Spammers know that we will apply exactly this procedure to uncover their whereabouts. To fool us, they may insert forged Received: lines that point to somebody else sending the message.

Since every mail server will always put its Received: line at the top, the spammers' forged headers can only be at the bottom of the Received: line chain. This is why we start our analysis at the top and don't just derive the point where an email originated from the first Received: line (at the bottom).

How to Tell a Forged Received: Header Line

The forged Received: lines inserted by spammers to fool us will look like all the other Received: lines (unless they make an obvious mistake, of course). By itself, you can't tell a forged Received: line from a genuine one.

This is where one distinct feature of Received: lines comes into play. As we've noted above, every server will not only note who it is but also where it got the message from (in IP address form).

We simply compare who a server claims to be with what the server one notch up in the chain says it really is. If the two don't match, the earlier Received: line has been forged.

In this case, the origin of the email is what the server immediately after the forged Received: line has to say about who it got the message from.

Are you ready for an example?

Example Spam Analyzed and Traced

Now that we know the theoretical underpinning, let's see how analyzing an junk email to identify its origin works in real life.

I've just received an exemplary piece of spam that we can use for exercise. Here are the header lines:

Received: from unknown (HELO (
  by mail1.infinology.com with SMTP; 16 Nov 2003 19:50:37 -0000
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" <27knxeppzk@yahoo.com>
Reply-To: "Reinaldo Gilliam" <27knxeppzk@yahoo.com>
To: ladedu@ladedu.com
Subject: Category A Get the meds u need lgvkalfnqnh bbk
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

Can you tell the IP address where the email originated?

Sender and Subject

First, take a look at the — forged — From: line. The spammer wants to make it look as if the message was sent from a Yahoo! Mail account. Together with the Reply-To: line, this From: address is aimed at directing all bouncing messages and angry replies to a non-existing Yahoo! Mail account.

Next, the Subject: is a curious agglomeration of random characters. It is barely legible and obviously designed to fool spam filters (every message gets a slightly different set of random characters), but it is also quite skillfully crafted to get the message across in spite of this.

The Received: Lines

Finally, the Received: lines. Let's begin with the oldest, Received: from [] by id <5416176-86323>; Sun, 16 Nov 2003 13:38:22 -0600. There are no host names in it, but two IP addresses: claims to have received the message from If this is correct, is where the email originated, and we'd find out which ISP this IP address belongs to, then send an abuse report to them.

Let's see if the next (and in this case last) server in the chain confirms the first Received: line's claims: Received: from unknown (HELO ( by mail1.infinology.com with SMTP; 16 Nov 2003 19:50:37 -0000.

Since mail1.infinology.com is the last server in the chain and indeed "my" server I know that I can trust it. It has received the message from an "unknown" host that claimed to have the IP address (using the SMTP HELO command). So far, this is in line with what the previous Received: line said.

Now let's see where my mail server did get the message from. To find out, we take a look at the IP address in brackets immediately before by mail1.infinology.com. This is the IP address the connection was established from, and it is not No, is where this piece of junk mail was sent from.

With this information, you can now identify the spammer's ISP and report the unsolicited email to them so they can kick the spammer off the net.

More From Us