当我尝试使用此代码在 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