当我尝试使用此代码发送Java电子邮件时,它会出错。谷歌搜索这个很长一段时间似乎无法找到解决方案。很多人说我需要添加(“mail.smtp.starttls.enable”,“true”)到我的道具,但它已经存在了。我们正在使用最新的Jar(javax.mail(1.5)
代码:
Message message = getMessage(session);
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(user.getEmail()));
message.setSubject(PROPERTIES_HELPER.getProperty("EMAIL_" + emailSuffix + "_USER_SUBJECT"));
message.setContent(constructEmail(emailSuffix, customer, user), "text/html");
Transport transport = session.getTransport("smtp");
transport.connect(HOST, PORT, USER, PASS);
Transport.send(message);
错误:
530 5.7.0 Must issue a STARTTLS command first. s3sm4537628eeo.3 - gsmtp