I’m building a email app (a web app which you interact with almost exclusively by email) and I’d like to be able to take a reasonable guess as to where my users are from using only their email headers. (I’m a firm believer that ‘defaults’ in web services should be as intelligent as possible!)
Does anyone with decent knowledge of modern email routing (ie. super-providers like google, yahoo etc) have any good ideas as to how to pull a user’s country from an email with a reasonable amount of accuracy and, if possible, a rough indication of how accurate this would be, so I can disregard the guess if it’s unlikely to be correct?
Ideas so far:
- Timezone (nowhere near accurate enough, but useful)
- email domain TLD (not very reliable, I have a .com TLD and I’m British)
- GeoIP of IPs in email header (not really sure whether this would work, which header would be the most reliable?)
Thanks for your head-cycles!
“normal” mail
I once wrote a thunderbird plugin which does the same and it exclusively used the top level domains to display the station of each route. A lesson learned there is that the mail may go over 10 or more servers until it reaches the recipient. You have to use the first route entry:
In that case, the sender is 84.185.130.22 – a whois on that IP gives us (correctly) Germany as the source of the mail.
Another example, first entry only:
which even contains
.nzas resolved hostname – this time correctly New Zealand. whois also gives you new zealand.webmail
You’d have to check if mails from i.e. gmail web interface also contain the correct IP, which I doubt. An example from gmail:
The sender IP is totally missing here, and the only information you get is the IP from google’s mail server. The time zone there is also the zone of the server, not the client’s time zone – it would be +02:00.
conclusion
In the end, no signal gives you 100% accuracy and you have to employ all of them.
Also, every single bit in an email may be forged – don’t forget that.