开发者

Determine POP/IMAP server from email address

Is there a way to determine POP or 开发者_运维百科IMAP server given the email address? I am building an application for non-technical users and I dont really want to bother them with asking their IMAP/POP servers. mail2web.com does this, but I am not sure how.


This is how Thunderbird does it

/**
18  * Try to guess the config, by:
19  * - guessing hostnames (pop3.<domain>, pop.<domain>, imap.<domain>,
20  *                       mail.<domain> etc.)
21  * - probing known ports (for IMAP, POP3 etc., with SSL, STARTTLS etc.)
22  * - opening a connection via the right protocol and checking the
23  *   protocol-specific CAPABILITIES like that the server returns.
24  */

http://mxr.mozilla.org/comm-central/source/mailnews/base/prefs/content/accountcreation/guessConfig.js


Thunderbird 3 does it too.. I'd take a look at the source code.
I think it's just a lookup table though..


There is nothing in a standard that dictates a POP/IMAP server for a given domain. Only convention or, as Joril suggests, lookup tables can be used. SMTP servers are different as there is a functional requirement to send the mail onto the next stop. Pick up (via POP/IMAP) is an entirely local domain admin issue. Sorry.

I guess you could take the domain and build a server name such that fred@mymail.com becomes pop.mymail.com and imap.mymail.com. Or perhaps take it further and interrogate the MX records and perform similar substitutions. Then you could run through your list of candidate servers looking for a POP/IMAP response. Might be a bit dodgy on the security front though.

Cheers, Dan


There's absolutely no way to do this correctly in general.

However, you can use tables of common mail providers to fill in defaults, and you could fill in smtp.example.com etc... but that will still fail in some simple cases, though, like my work system where everything is on mail.wherever.com on unusual port numbers. So in the end, the user must be able to override whatever you do.

If you really want it to be general, you're going to have to deal with certificates and EAP as well.


Thunderbird does a good job. It's method is described here https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration. Below is a excerpt of the documentation.

All the lookup mechanisms use the email address domain as base for the lookup. For example, for the email address fred@example.com , the lookup is performed as (in this order):

  1. tb-install-dir/isp/example.com.xml on the harddisk
  2. check for autoconfig.example.com
  3. look up of "example.com" in the ISPDB
  4. look up "MX example.com" in DNS, and for mx1.mail.hoster.com, look up "hoster.com" in the ISPDB
  5. try to guess (imap.example.com, smtp.example.com etc.)

We may in the future add DNS SRV records as supported mechanism in the future, but we currently do not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜