I am using play 2.0 for a project and i am trying to send email to user. I use this plugin [https://github.com/typesafehub/play-plugins/tree/master/mailer].
In my Build.scala I added
"com.typesafe" %% "play-plugins-mailer" % "2.0.4"
and in conf/play.plugins
1500:com.typesafe.plugin.CommonsMailerPlugin
In my conf/application.conf I have the settings
smtp.host=smtp.gmail.com
smtp.port=25
smtp.ssl=true
smtp.tls=false
smtp.username="[email protected]"
smtp.password="xxxxxxx"
My controller action is
public static Result sendEmail(String recipt, String title, String sender ){
MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email();
mail.setSubject(SUBJECT);
mail.addRecipient(recipt);
mail.addFrom(sender);
String body = views.html.teams.mailBody.render(recipt, title, sender).body();
mail.sendHtml(body);
return ok();
}
I get the following error
[EmailException: Sending the email to the following server failed : smtp.gmail.com:25]
What I am doing wrong. Any help will be highly appreciated.
Thanks
The SMTP configuration for Gmail is different (secured with TLS enabled on port 587).
Try with this config:
smtp.host=smtp.gmail.com
smtp.port=587
smtp.ssl=true
smtp.tls=true
smtp.username="[email protected]"
smtp.password="xxxxxxx"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With