sending Email with outlook (TLS instead of SSL)

2,676 views
Skip to first unread message

Daniel SAWAN

unread,
Feb 2, 2015, 6:03:12 PM2/2/15
to ninja-f...@googlegroups.com

Hi,

I saw the tutorial to send an email, the application.conf should look like :

smtp.host=...     // Hostname of the smtp server (e.g. smtp.mycompany.com)

smtp.port=...     // Port of the smtp server  (e.g. 465).

smtp.ssl=...      // Whether to enable ssl (true or false)

smtp.user=...     // Username to access the smtp server

smtp.password=... // The password

smtp.debug=...    // Enable logging of a huge amount of debug information (true or false)


This work perfectly well with gmail because gmail use SSL smtp.

But outlook use TLS encryption so is it possible to enable somewhere starttls.

The error I got is : Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

I tried to put in the conf :

smtp.tls=true

smtp.starttls=true

smtp.starttls.enable=true

 

but nothing work.


Thanks for your help

 

 

Daniel SAWAN

unread,
Feb 5, 2015, 3:53:44 PM2/5/15
to ninja-f...@googlegroups.com
By the way i found a work arround for TLS by coding my own method but not using the email tool integrated in Ninja :

        private static void sendEmail365(String objet, String from, String to, String html) {

final String username = "yo...@email.com";
final String password = "yourpassword";
 
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.office365.com");
props.put("mail.smtp.port", "587");
 
Session session = Session.getInstance(props,
 new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
 });
 
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
message.setSubject(objet);
message.setText(html, "utf-8", "html");
Transport.send(message);
} catch (MessagingException e) {
e.printStackTrace();
}
}

But it would be cool if Ninja could support TLS authentification !
Reply all
Reply to author
Forward
0 new messages