CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2001
    Location
    United States
    Posts
    725

    How to extract sender's IP address from e-mail header programmatically/manually?

    Hello,

    I was wondering how to, within an e-mail header, extract the sender's IP address? I need to do this programmatically, but if someone could inform be of how to do it manually, I could probably be able to figure out the coding aspect of it myself...hopefully. Thanks.

  2. #2
    Join Date
    May 2001
    Location
    United States
    Posts
    725
    hmm, well, is it even possible to get the IP address from the sender of an e-mail by looking at the e-mail header? Thought that everyone just read this post and thought I was going a bit cuckoo with my question...

  3. #3
    Join Date
    Jul 2001
    Location
    UK
    Posts
    329
    I am not sure it is. The way to tell, if you have access to a Unix box or somesuch, is to send yourself an email. Email messages on a lot of Unix/Linux boxes use the standard sendmail mail handler, that saves emails as text files. You can then view the whole email, including all the headers.

    The problem with a lot of email programs today is that they are written for lusers - people who couldn't care less about anything to do with computers. I generally have to tweak my web email accounts so that they always display headers, and even although Outlook offers an option to display email headers, I don't trust it at all.

  4. #4
    Join Date
    May 2001
    Location
    United States
    Posts
    725
    Thanks for the tip jontom! I once read an article somewhere that stated that it was possible to do so. However, when I tried sending myself e-mails to my outlook(earthlink) and yahoo accounts, I could not locate my IP address on those headers. Is there a standard e-mail header style, because the ones that I saw on outlook and yahoo looked different from the ones in the article that I read.

  5. #5
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    Most mail clients have some option where you can toggle between seeing the full mail headers, or not.

    For example, for Yahoo mail, there is a link just above the message (along the right margin) that reads either "Full Headers" or "Brief Headers".

    In Outlook Express, you can right click on any message entry in a mailbox and select "Properties" then "Details" etc.

  6. #6
    Join Date
    Jul 2001
    Location
    UK
    Posts
    329
    There isn't really a standard set of headers. What each mail client or server puts in the header is implementation dependant. The only standard headers I can think of are the "From <email addr>" and "Subject: <subject text>", and the reply-to headers, although the "From: <fancy from address>" is becoming quite common too.

    Generally the protocol is to ignore anything you don't understand.

    Here's a weird thing. I have a Linux email account, a Yahoo email account, and a corporate Outlook account. If I send a zipfile attachment from Outlook, it is attached by UUEncoding,a nd placing it in the body of the message. Both Yahoo and Linux accounts interpret it correctly. If I send a zipfile attachment from my Linux account by piping the UUEncode output to mail, then Outlook reads it correctly, but Yahoo does not. Quite odd. I haven't looked at the headers enough to sort it out - too lazy.

  7. #7
    Join Date
    May 2001
    Location
    United States
    Posts
    725
    hmm, the article I read stated that the IP would be located in the "Receive:" section of the header. However, I often see more than one IP there (and also elsewhere in the header), though I don't think some are the IP's of the sender. I traced some of them, and one led to my school's firstclass client, some to an AT&T area, and some I couldn't track at all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured