-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't configure office365 SMTP on play mailer 5.0.0-M1 #98
Comments
Have you tried to enable |
Thanks for getting back to me. If you see to office365 SMTP submission documentation, It is only tls enabled. so there is no way ssl gonna work. But I'll give it a try. well I implemented mailing service using |
@HirenPatel2791 Did it work with enabling ssl? |
On a side note, I think it could be great to add the configuration for common mail provider like Gmail or Office 365 in the user manual: https://github.com/playframework/play-mailer/blob/master/user-manual.adoc |
@mkurz no it didn't work with ssl as expected. I'll share my code:
Session session = Session.getInstance(props, new Authenticator() {
protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
return new javax.mail.PasswordAuthentication(cfg.getString("myEmail.user"),cfg.getString("myEmail.password") );
}
});
try {
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
// Set Subject: header field
message.setSubject(emailSubject);
// Now set the actual message
message.setContent("Hi "+ fname + "," + emailBodyStringEnd, "text/html");
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
} this is config:
I'm using shared mailbox so user and from is different. |
Thanks for sharing. I will try to find the root cause. |
Sorry but I can't reproduce this issue. val email = Email(
"Hello",
"[email protected]",
Seq("[email protected]"),
bodyText = Some("Hi Guillaume")
)
mailerClient.send(email)
I also tried to use this configuration (similar to what you are using):
NOTE: Your code is working as well, here's the Scala version: val props = new Properties()
props.setProperty("mail.smtp.from", "[email protected]")
props.setProperty("mail.smtp.host", "smtp.office365.com")
props.setProperty("mail.smtp.port","587")
props.setProperty("mail.smtp.auth", "true")
props.setProperty("mail.smtp.starttls.enable", "true")
val session = javax.mail.Session.getInstance(props, new Authenticator {
override def getPasswordAuthentication = new javax.mail.PasswordAuthentication("[email protected]","********")
})
val message = new MimeMessage(session)
message.setFrom(new InternetAddress("[email protected]"))
message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"))
message.setSubject("Hello")
message.setContent("Hi Guillaume", "text/html")
Transport.send(message) I did try to use a different address between I would be curious to understand why this is not working. Could someone give it a try ? @mkurz are you using Office 365 ? |
@Mogztter No I am not using Office 365 right now. But I am working on a project for a client of mine and I think they use Office 365 AFAIK - so maybe I have to send out emails with this provider as well in the coming weeks. If I find out something I will let you know of course. |
@mkurz Ok great, thanks 😄 |
Reading again this issue, I'm pretty sure the problem was a short @HirenPatel2791 Do you find a solution ? Is it working now ? |
I can confirm it is working with Office365.com. |
@adis-me can you share your solution. |
@HirenPatel2791 Is your antivirus blocking smtp requests? See #115 |
@HirenPatel2791 My configuration looks like: smtpConfiguration = new SMTPConfiguration(
"smtp.office365.com", // host
587, // port
Boolean.FALSE, // ssl
Boolean.TRUE, // tls
Option.apply("[email protected]"), // user
Option.apply("VeryHardPassword"), // password
Boolean.FALSE, // debug
Option.apply(60000), // timeout in ms
Option.apply(60000), // connection timeout in ms
Boolean.FALSE // mock
); And then I send the mail: Email email = new Email()
.setSubject("Some subject")
.setFrom("[email protected]")
.addTo("[email protected]")
.setBodyHtml(errorBuilder.toString());
// send mail
new SMTPMailer(smtpConfiguration).send(email); |
Thanks for sharing this @adis-me |
update spf records of that domain according to office365 |
I recently tried this plug in.. and was able to send mails using google smtp.. Now in the same application I'm trying to integrate my office365 mailbox and send emails out. for that I followed this
application.conf:
but throws an exception:
The problem I could suspect is tls version which should be >=1.0 for office365. But don't know how to check it.
I tried hard to find solution but couldn't.
any hint will be helpful.. thanks
The text was updated successfully, but these errors were encountered: