我正在尝试使用Bill the Lizard 的代码使用 Google Apps 发送电子邮件。我收到此错误:
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. f3sm9277120nfh.74
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:81)
at SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:44)
比尔的代码包含下一行,这似乎与错误有关:
props.put("mail.smtp.starttls.enable","true");
但是,它没有帮助。
这些是我的导入语句:
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
有谁知道这个错误?