简体   繁体   中英

How to get IMAP Host name from email address in java?

I am trying to connect to ISP mail server by using IMAP protocol in java. My requirement is client provides mail addresses, username and password. I have to connect the mail Server and store conent of the message to the database. Here the mail address may belongs to any ISP.

The javax.mail.server has method connect(String host,String UserName,String password) .

My problem is different ISPs and their sub-domains have different host addresses.

For instance

gmail host address is imap.gmail.com

yahoo host address is imap.mail.yahoo.com

yahoo Uk host address is imap.mail.yahoo.co.uk

How to get host address by reading the provided email address?

like by looking at abc@gmail.com, i can find it belongs to gmail domain, From the domain how can i find host address?

kindly suggest me the best approach, I am ready to user any other protocols like POP, as long as it satisfies my requirement.Suggest me if any alternative exists also.

Thanks in advance.

There's no standard way of obtaining that information.

You can try to mimic Mozilla in their autoconfiguration , or follow RFC 6186 which provides a useful and standard-compliant way of what you're looking for. However, these mechanisms are voluntary, their adoption varies and you cannot rely on them at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM