Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email exception in play 2.0

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

like image 831
Umair Avatar asked Dec 15 '22 15:12

Umair


1 Answers

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"
like image 89
ndeverge Avatar answered Dec 30 '22 06:12

ndeverge