Removing Sender’s IP Address From Email’s Received: From Header

When sending an email, Sendmail and other SMTP servers, will log your originating device’s: name (hostname or computer name), IP address, and IP’s reverse DNS lookup, into the first “Received: from” Header line…

Received: from (ip-address.reverse.lookup [ip.address])

This is a problem because:

  1. It’s sensitive information that contains your location.
  2. It can further contain meta-data about your reader (ex: Outlook, Windows Live Mail, Mail App, Mozilla Thunderbird).
  3. Spam tools will detect a Residential IP address which will prevent email delivery.

The solution to hide the client’s (sender’s) IP address is to redefine the SMTP server’s use of RECEIVED_HEADER.

The standard definition of this header can be found in file:

define(`_REC_AUTH_', `$.$?{auth_type}(authenticated')
define(`_REC_FULL_AUTH_', `$.$?{auth_type}(user=${auth_authen} $?{auth_author}author=${auth_author} $.mech=${auth_type}')
define(`_REC_HDR_', `$?sfrom $s $.$?_($?s$|from $.$_)')
define(`_REC_END_', `for $u; $|;
define(`_REC_TLS_', `(version=${tls_version} cipher=${cipher} bits=${cipher_bits} verify=${verify})$.$?u')
define(`_REC_BY_', `$.by $j ($v/$Z)$?r with $r$. id $i$?{tls_version}')
define(`confRECEIVED_HEADER', `_REC_HDR_
        _REC_AUTH_$?{auth_ssf} bits=${auth_ssf}$.)

To strip out all private info (senders’s/client’s IP address) of the initial client connection, you would basically remove that entire connection’s info (and also of all the connections before it), and make it look like the email originated from the SMTP server itself…

Edit file:

define(`confRECEIVED_HEADER',`by $j ($v/$Z)$?r with $r$. id $i; $b')dnl

Then rebuild and restart sendmail:

[root@private mail]# m4 /etc/mail/ > /etc/mail/
[root@private mail]# service sendmail restart


I’ve been doing this for YEARS without any issues whatsoever to be able to send out emails from my PC (using Outlook and Windows Live Mail) to my clients without triggering spam filters, and to prevent privacy leaks.

2 thoughts on “Removing Sender’s IP Address From Email’s Received: From Header”

  1. Hello ,

    I referred link to solve my issue, I need to remove the server’s IP address from the mail sent with sendmail from one of my feedback.php page.
    I have few queries when you say to edit the file “/etc/mail/” where exactly this line has to be added? I have added at the end of the document.
    ” define(`confRECEIVED_HEADER’,`by $j ($v/$Z)$?r with $r$. id $i; $b’)dnl”

    Also, do we need to make changes inside “/usr/share/sendmail-cf/m4/cfhead.m4″ file

    Thanks in Advance,
    Anita Bharambe

    1. You only edit

      The cfhead.m4 file is for source-code reference, to show you what is going on under it all. As most of this stuff makes no sense.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>