gmail sending: 530 5.7.0 Must issue a STARTTLS command first

gmail sending: 530 5.7.0 Must issue a STARTTLS command first

无论是配置(数据库/properties文件),还是code,只要遇到
530 5.7.0 Must issue a STARTTLS command first

应该考虑以下2点
1) javamail的version (基本不需要考虑)

2) 保证加入粗体部分 (最主要的原因)

props.put("mail.smtp.user","username"); 
props
.put("mail.smtp.host", "smtp.gmail.com");
props
.put("mail.smtp.port", "25");
props
.put("mail.debug", "true");
props
.put("mail.smtp.auth", "true");
props
.put("mail.smtp.starttls.enable","true");
props
.put("mail.smtp.EnableSSL.enable","true");

props
.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");  
props
.setProperty("mail.smtp.socketFactory.fallback", "false");  
props
.setProperty("mail.smtp.port", "465");  

你可能感兴趣的:(gmail sending: 530 5.7.0 Must issue a STARTTLS command first)