1

Can my IP address ever be included in the header of emails I send? Or do email servers never include my IP address in my emails' headers?

2
  • 3
    That depends; are you using a webmail client or sending emails directly with SMTP? Commented Aug 24, 2020 at 22:23
  • @multithr3at3d SMTP with a standalone email client
    – Geremia
    Commented Aug 25, 2020 at 16:29

2 Answers 2

4

If you ask can an IP address of a sender ever be included in the email headers, the answer is obviously yes. What happens in your situation is easy enough to test by sending an email message as you usually do to an email address where you can investigate the full headers. The behaviour of the first-hop connection between your mail user agent MUA (or web browser in case of a webmail) and the email server doesn't change between two messages, so the results are generalizable for all the messages sent using the same method.

Here are some examples of the current situation, where 198.51.100.123 is the IP address:

  • SMTP submission. By the specification in RFC 5321, 4.4 the SMTP protocol also used for message submission (RFC 6409) MUST record trace information:

    When an SMTP server receives a message for delivery or further processing, it MUST insert trace ("time stamp" or "Received") information at the beginning of the message content, as discussed in Section 4.1.1.4.

    This line MUST be structured as follows:

    • The FROM clause, which MUST be supplied in an SMTP environment, SHOULD contain both (1) the name of the source host as presented in the EHLO command and (2) an address literal containing the IP address of the source, determined from the TCP connection.

    E.g. both Postfix & Exim adds a Received header on submission just like every SMTP server that processes the message. This header contains the hostname the MUA introduced itself with (that could e.g. the computer name like User-PC or local IP address [192.168.1.100]), the reverse DNS hostname of the public IP address and the address from which the connection originated, possible TLS version and ciphersuite used etc., e.g. (Postfix):

    Received: from User-PC (198-51-100-123.dyn.example.com [198.51.100.123])
        (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
        by mail.example.com (Postfix) with ESMTPSA id 7890ABCDEF
        for <[email protected]>; Tue, 25 Aug 2020 15:00:00 +0000 (UTC)
    

    or (Exim):

    Received: from [198.51.100.123] (port=36031 helo=User-PC)
        by mail.example.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
        (Exim 4.94)
        (envelope-from <[email protected]>)
        id 1abcde-0002fG-HI
        for [email protected];  Tue, 25 Aug 2020 15:00:00 +0000
    
  • MAPI. Messaging Application Programming Interface (MAPI) and MAPI over HTTP are used by Microsoft Exchange & Office 365 as a server and e.g. Outlook as a client. Currently with Office 365 the IP address gets recorded in the x-originating-ip header.

    x-originating-ip: [198.51.100.123]
    

    This header was originally used by Hotmail between 1999 and 2012, but was then replaced with encrypted X-EIP. Although the x-originating-ip header isn't standardized, it's used by some other services too, including e.g. GoDaddy Webmail Service.

  • Gmail. Whether you use the webmail or SMTP, the first-hop connection isn't recorded in the Received headers and there's no x-originating-ip header, neither.

    However, there's an X-Google-Smtp-Source header containing 68 bytes of binary information encoded in base64. Although this doesn't seem to directly contain the IP address, Google probably has the missing piece of information and can use this header to track your original IP address.

  • Webmails have different practices.

    • Squirrelmail webmail adds a Received header stating that the webmail client received the message using HTTP.

      Received: from 198.51.100.123
              (SquirrelMail authenticated user joe.bloggs)
              by webmail.example.com with HTTP;
              Tue, 25 Aug 2020 15:00:00 +0000
      

      This information can be encrypted with configuration parameter $encode_header_key, but the configuration section has a comment stating it's not bulletproof.

    • Roundcube has two configuration parameters and I think it defaults to not including this information in the messages.

      http_received_header_encrypt
      Whether or not to encrypt the IP address and the host name. These could, in some circles, be considered as sensitive information; however, for the administrator, these could be invaluable help when tracking down issues.

      http_received_header
      Add a received header to outgoing mails containing the creators IP and hostname.

3
  • The SMTP spec itself requires the addition of a Received header to denote the client IP. It's only when the mail isn't originally submitted via SMTP (as you noted) that you have other methods, but it eventually goes to SMTP and then you have logs for each IP (e.g. the webmail server's IP).
    – Adam Katz
    Commented Aug 25, 2020 at 21:16
  • Thanks, Adam! I've added this requirement from RFC 5321, 4.4 to my answer. Commented Aug 26, 2020 at 9:22
  • Gmail. Whether you use the webmail or SMTP, the first-hop connection isn't recorded in the Received, I have just sent an email to myself from a Google email to a non-Google email, using SMTP and local client. The first hop connection is recorded with my IP address in the first "Received from", just before the "To" Commented Mar 15, 2021 at 1:51
3

Years ago, many webmail services (such as Hotmail and Yahoo Mail) used to include a X-Originating-Ip header in outgoing messages, which indicated IP address that the sender was using to connect to the webmail service to send the message. But, most of those services either encode this header now, or no longer include it. See https://en.wikipedia.org/wiki/X-Originating-IP for more info.

1
  • There's still no single widely used practice in contrary to what has been stated in this answer. Therefore, this is a bit too generalized, the real answer being it varies. If the question is ever then the answer is yes. I've added some examples based on recents emails I've received. Commented Aug 25, 2020 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .