我总是会收到错误消息:
javax.mail.NoSuchProviderException: Invalid protocol: null
at javax.mail.Session.getProvider(Session.java:525)
at javax.mail.Session.getStore(Session.java:620)
at javax.mail.Session.getStore(Session.java:600)
at javax.mail.Session.getStore(Session.java:586)
at de.jankrb.mailcrawler.methods.CheckAll.check(CheckAll.java:23)
at de.jankrb.mailcrawler.Launcher.main(Launcher.java:10)
我什么也没尝试,因为我没有在网上找到任何东西。
这很麻烦:
Properties properties = new Properties();
properties.put("mail.transport.protocol", "smtp");
properties.put("mail.smtp.host", HOST);
properties.put("mail.user", USER);
properties.put("mail.password", PASS);
Session session = Session.getDefaultInstance(properties);
Store store = session.getStore();
store.connect(HOST, USER, PASS);
Launcher.java:10仅使用该方法,其中上面的代码片段位于其中。
答案 0 :(得分:0)
Properties properties = new Properties();
properties.put("mail.store.protocol", "pop3");
properties.put("mail.pop3.host", HOST);
properties.put("mail.pop3.port", "995");
properties.put("mail.pop3.ssl.trust", "true");
//properties.put("mail.pop3.starttls.enable", "true");
Session session = Session.getDefaultInstance(properties);
Store store = session.getStore("pop3s");
store.connect(HOST, USER, PASS);
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
这是我正在使用的代码及其工作方式。还是谢谢