日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

oracle ssl发送邮件,使用javax.mail发送带有ssl的电子邮件

發布時間:2025/3/21 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle ssl发送邮件,使用javax.mail发送带有ssl的电子邮件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想使用gmail作為smtp服務器發送電子郵件.

這是我的代碼,我沒有讓它工作……

運行testSettings()后,我得到調試輸出,然后它就停止了.沒有超時,沒有錯誤,沒有……

public void testSettings() {

final String username = Settings.get("benutzername");

final String password = Settings.get("passwort");

Properties props = new Properties();

props.put("mail.transport.protocol", "smtps");

props.put("mail.smtp.starttls.enable", "true");

props.put("mail.smtp.socketFactory.port", Settings.get("port"));

props.put("mail.smtp.socketFactory.class",

"javax.net.ssl.SSLSocketFactory");

props.put("mail.smtp.auth", "true");

props.put("mail.smtp.host", Settings.get("server"));

props.put("mail.smtp.port", Settings.get("port"));

props.put("mail.smtp.timeout", "10000");

props.put("mail.smtp.ssl.checkserveridentity", "false");

props.put("mail.smtp.ssl.trust", "*");

props.put("mail.smtp.connectiontimeout", "10000");

props.put("mail.smtp.debug", "true");

props.put("mail.smtp.socketFactory.fallback", "false");

Session session = Session.getInstance(props,

new javax.mail.Authenticator() {

protected PasswordAuthentication getPasswordAuthentication() {

return new PasswordAuthentication(username, password);

}

});

session.setDebug(true);

try {

Message message = new MimeMessage(session);

message.setFrom(new InternetAddress("myemail@gmail.com"));

message.setRecipients(Message.RecipientType.TO,

InternetAddress.parse("myemail@gmail.com"));

message.setSubject("Testing Subject");

message.setText("test");

Transport transport = session.getTransport("smtps");

transport.send(message);

// Transport.send(message);

System.out.println("Done");

} catch (MessagingException e) {

// throw new RuntimeException(e);

}

}

DEBUG: setDebug: JavaMail version 1.4.7

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle]

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的oracle ssl发送邮件,使用javax.mail发送带有ssl的电子邮件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。