Defining a POP / IMAP server from an email address

Is there a way to determine the POP or IMAP server based on the email address? I am creating an application for non-technical users, and I really do not want to bother them by asking their IMAP / POP servers. mail2web.com does this, but I'm not sure how to do it.

+4
source share
5 answers

So 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

+6
source

Thunderbird 3 does this too. I would look at the source code.
I think this is just a lookup table, though ..

+2
source

There is nothing in the standard that the POP / IMAP server dictates for a given domain. Only a convention or, as Joril suggests, lookup tables can be used. SMTP servers are different because there is a functional requirement to send mail to the next stop. Pickup (via POP / IMAP) is a completely local domain administration. Unfortunately.

I think you could take a domain and create a server name so that fred@mymail.com becomes pop.mymail.com and imap.mymail.com. Or perhaps take it further and interrogate the MX records and make similar replacements. You can then run the list of candidate servers looking for a POP / IMAP response. Perhaps it will be a little dodgy on the security front.

Cheers, dan

+1
source

There is absolutely no way to do this correctly in general.

However, you can use the tables of common mail providers to fill in the default values, and you can fill in smtp.example.com, etc .... but it will still be inoperable in some simple cases, although, like my working system, where everything is on mail.wherever.com on unusual port numbers. Therefore, in the end, the user should be able to redefine everything that you do.

If you really want it to be shared, you will also have to deal with certificates and EAP.

0
source

Thunderbird does a great job. This method is described here https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration . The following is a snippet of documentation.

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

  • tb-install-dir / isp / example.com.xml on your hard drive
  • check autoconfig.example.com
  • find "example.com" in ISPDB
  • find "MX example.com" in DNS, and for mx1.mail.hoster.com find "hoster.com" in ISPDB
  • try to guess (imap.example.com, smtp.example.com, etc.)

In the future, we can add DNS SRV records as a supported mechanism, but we do not currently do this.

0
source

Source: https://habr.com/ru/post/1299085/


All Articles