您应该将端口更改为
587,我测试了您的代码,并且工作正常
如果仍然发生错误,请将会话变量更改为以下代码:
Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(userName, password); }});


