我有这个在 Eclipse 中运行良好的 Java 程序,它使用 Apache commons 邮件库 1.4 发送电子邮件:
import org.apache.commons.mail.*;
public class SendEmail {
public static void main(String[] args) throws EmailException {
HtmlEmail email2 = new HtmlEmail();
email2.setHostName("smtp.ionos.com");
email2.setAuthentication("[email protected]", "abc123");
email2.setFrom("[email protected]", "Jon Doe");
email2.setSSLOnConnect(true);
email2.setSubject("this is the subject");
email2.setHtmlMsg("<h1>HELLO WORLD NOW WORKS !!! </h1>");
email2.addTo("[email protected]", "Julius Cesar");
System.setProperty("https.protocols", "TLSv1.2,TLSv1.3");
email2.send();
System.out.println("EMAIL SENT !!!!");
}
}
当我在 Netbeans 中运行 same 程序时,出现错误
email2.send()
:
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.ionos.com, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version
Eclipse 和 Netbeans 都运行 Java 15.0.2。 Eclipse 和 Netbeans 有什么区别?如何解决这个问题?