【发布时间】:2018-09-01 18:48:21
【问题描述】:
我得到这个错误和超时异常。
输入代码:
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host","smtp.gmail.com");
props.put("mail.smtp.port", "587");
props.put("mail.debug", "true");
调试 SMTP:尝试连接到主机“smtp.gmail.com”,端口 587,isSSL true Exceptioninthread“main”java.lang.RuntimeException:com.sun.mail.util.MailConnectException:无法连接到主机,端口:smtp.gmail.com,587;超时 -1。
【问题讨论】:
-
发布堆栈跟踪、生成它的代码等以重现问题。
-
顺便说一句,您正在使用代码 sn-p 来编写简单的英语,反之亦然
-
@Aniket sahrawat 属性 props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host",host); props.put("mail.smtp.port", 端口); props.put("mail.debug", "true");
-
host="smtp.gmail.com";端口=:587";
-
yes..Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); @莫里斯佩里
标签: java smtp jakarta-mail