简体   繁体   English

如何从Java中的电子邮件地址获取IMAP主机名?

[英]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. 我正在尝试使用Java中的IMAP协议连接到ISP邮件服务器。 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. 此处的邮件地址可以属于任何ISP。

The javax.mail.server has method connect(String host,String UserName,String password) . javax.mail.server具有方法connect(String host,String UserName,String password)

My problem is different ISPs and their sub-domains have different host addresses. 我的问题是不同的ISP及其子域具有不同的主机地址。

For instance 例如

gmail host address is imap.gmail.com gmail主机地址是imap.gmail.com

yahoo host address is imap.mail.yahoo.com 雅虎主机地址是imap.mail.yahoo.com

yahoo Uk host address is imap.mail.yahoo.co.uk yahoo英国的主机地址是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? 就像通过查看abc@gmail.com一样,我可以找到它属于gmail域,如何从该域中找到主机地址?

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. 请给我最好的方法,我愿意使用其他任何协议,例如POP,只要它满足我的要求。如果有其他选择,也建议我。

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. 您可以尝试模仿Mozilla的自动配置 ,也可以遵循RFC 6186RFC 6186提供了一种有用且符合标准的查找方式。 However, these mechanisms are voluntary, their adoption varies and you cannot rely on them at all. 但是,这些机制是自愿的,采用的方式各不相同,您完全不能依赖它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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