public class ConnectGmail {
public static void main(String args[]) throws Exception {
PasswordAuthentication authentication;
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imap");
Session session = Session.getDefaultInstance(props);
Store store = session.getStore("imap");
try {
store.connect(host , user , "password");
} catch (Exception e) {
e.printStackTrace();
}
}
}
得到这个错误。我几乎所有的协议无法连接到我的邮件服务器(JAVA)
javax.mail.MessagingException: Connection refused: connect;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at javax.mail.Service.connect(Service.java:169)
at ConnectGmail.main(ConnectGmail.java:26)
任何帮助,试过?
'HOST'或'host'? 'USR'或'user'? “密码”或“身份验证”对象? – sarnold 2011-03-08 08:58:43