1

I've made a little application for email parsing for a certain niche of business. That requires access to the user's email. I currently have a small settings menu where I ask the user to enter the relevant information for this, mail server, protocol, port, email and password. The problem is I'm dealing with a clientele that is not at all computer literate and asking them to go on their email providers site and find this information is a headache for them.

How much info can I get myself just from the email? Can I somehow track down the relevant info (mail server, protocol, port) myself so I can help new users config their system?

Of course this is easy if they use a big email provider like gmail or hotmail, but some of my customers have their own websites and email server (usually by paying a third party to set them up 2 years ago and are unlikely to have the information necessary/understand how to go on the hosting service website and get the email server info).

2
  • 1
    You can't get this from an address alone . . . you could probably add some logic to your program to try and guess the mail server (try probing for POP and IMAP on the standard ports), but if they're using non-standard ports, you'd be out of luck, and would have to fallback to prompting for the info.
    – ernie
    Nov 15, 2013 at 21:26
  • All you can assume is what's in the DNS record. You really have no idea what "server" that DNS record will redirect you to.
    – surfasb
    Nov 16, 2013 at 22:26

1 Answer 1

3

Expanding on @ernies comment, the answer is "it depends".

You can typically take the domain name part of the email and find the MX records for it. Very often (but not always) this will give you a hint as to the incoming mail server - for example "mail.example.com" might imply both smtp and pop3 are handled through "mail.example.com". Similarly "smtp.example.com" might imply "pop.example.com" or "pop3.example.com".

There are also a limited number of "standard" ports - you can typically check to see if the server will answer on these (for example smtp would be 25, 26, 4xx and 587). Similarly standard ports for POP3(s) - 110 and 995, and IMAP - 143 and 993. If these ports are open you can probe them to see if you can send or receive email through them. Similarly you can write tests for SMTP to check if it handles SSL on the ports it answers on.

None of these are definitive answers though.

3
  • Thanks for the suggestion, I found mxtoolbox.com it helps track mx records. As for the ports, I know it's a gray area without a clear yes or no answer but would you say it's ok for me to launch a nmap scan on the mail server once I have found it? Nov 16, 2013 at 11:06
  • I don't think ts OK to portscan all the ports on the system, but, as a system administrator, checking the ports commonly associated with mail would not worry me. As this uses tcp, you may be able to get better traction using netcat or an API to connect to common ports using TCP.
    – davidgo
    Nov 16, 2013 at 20:17
  • Another approach to build in, if you are trying to make the most comprehensive attempt you can, is to look at the Autodiscover system Outlook and Thunderbird can use - Documentation is a bit sparce, but look at forums.cpanel.net/f145/…. Thunderbird can do something similar, but does not rely as much on https.
    – davidgo
    Nov 16, 2013 at 20:18

You must log in to answer this question.

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