700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > oracle ssl发送邮件 使用javax.mail发送带有ssl的电子邮件

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

时间:2020-07-19 05:41: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",

".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@"));

message.setRecipients(Message.RecipientType.TO,

InternetAddress.parse("myemail@"));

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 "", port 587, isSSL false

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。