You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过外部Java代码(IMAP)从IBM Domino Lotus获取邮件?

连接IBM Domino Lotus邮件服务器时遭遇UnknownHostException问题

我此前借助JavaMail API成功实现了Gmail的连接、邮件获取与读取功能,现在尝试用类似方式通过外部Java代码连接IBM Domino Lotus服务器,读取收件箱邮件,但遇到了异常。

使用的代码

String host = "<Host name>";
String username = "<User Name>";
String password = "<password>";

Properties properties = new Properties();
properties.setProperty("mail.store.protocol", "imap");
properties.setProperty("mail.imap.host", host);
properties.setProperty("mail.imap.port", "143");

try {
    Session emailSession = Session.getInstance(properties);
    Store emailStore = emailSession.getStore("imap");
    emailStore.connect(host, username, password);
            
    //Getting Inbox folder
    Folder emailFolder = emailStore.getFolder("INBOX");
    emailFolder.open(Folder.READ_ONLY);
            
    Message[] messages = emailFolder.getMessages(); 
    System.out.println("No Of Mails : "+messages.length);
            
    //closing
    emailFolder.close(false);
    emailStore.close();
}
catch(NoSuchProviderException nspe) {
    System.out.println(nspe.getMessage());
    System.out.println(me.toString());
    nspe.printStackTrace();
}
catch(MessagingException me){
    System.out.println(me.getMessage());
    System.out.println(me.toString());
    me.printStackTrace();
}
catch(Exception e) {
    System.out.println(e.getMessage());
    System.out.println(me.toString());
    e.printStackTrace();
}

抛出的异常

执行*emailStore.connect(host, username, password);*这一行时,抛出以下异常:

javax.mail.MessagingException: <Host name>;;
  nested exception is:
    java.net.UnknownHostException:  <Host name>
javax.mail.MessagingException:  <Host name>;;
  nested exception is:
    java.net.UnknownHostException: <Host name>

    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:611)
    at javax.mail.Service.connect(Service.java:291)
    at javax.mail.Service.connect(Service.java:172)
    at package1.MyClass.main(MyClass.java:40)
Caused by: java.net.UnknownHostException:  <Host name>
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:267)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:103)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:578)
    ... 3 more

已尝试的操作

  • 将端口改为993
  • 设置ssl.enable属性为true
  • 确认服务器端已启用IMAP服务

但以上操作后仍抛出相同异常,不确定当前连接IBM Domino Lotus的方式是否正确。

内容的提问来源于stack exchange,提问作者Manish Chauhan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 22:42:08