xpg94
xpg94

Reputation: 513

gmail smtp exception in java play framework

I was reading about what is the best way about sending email through play framework (java). I have found this: https://github.com/playframework/play-mailer and I followed the instructions. I use gmail.

Here is what I added into application.conf:

play.mailer.host="smtp.gmail.com"
play.mailer.port=587
play.mailer.ssl=yes
play.mailer.tls=no
play.mailer.user="[email protected]"
play.mailer.password="blabla"

and here is my controller:

Email email = new Email();
        email.setSubject("Confirmation");
        email.setFrom("Mister FROM <[email protected]>");
        email.addTo("Miss TO <[email protected]>");
        email.setBodyText("A text message");
        email.setBodyHtml("<html><body><p>An <b>html</b> message</p></body></html>");
        mailerClient.send(email);

Everything compiles with no problems, but when I run it I get this exception:

[EmailException: Sending the email to the following server failed : smtp.gmail.com:587] at  mailerClient.send(email);

Upvotes: 0

Views: 197

Answers (1)

Samir
Samir

Reputation: 7152

You have to change the change the gmail configuration also . like- Go to your gmail account then in setting section go to the "Forwarding and POP/IMAP" tab then enable "Enable IMAP".

Hope this will help if you are sending the correct credential.

Upvotes: 1

Related Questions