Skip to content
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

Connect with heroku #102

Closed
johnmara opened this issue Jun 28, 2016 · 6 comments
Closed

Connect with heroku #102

johnmara opened this issue Jun 28, 2016 · 6 comments
Labels

Comments

@johnmara
Copy link

johnmara commented Jun 28, 2016

Hello, I'm using Play Framework 2.5 and I've deployed my app on Heroku.
The problem is that the same configuration that works locally, is not working on heroku.
Specifically my application.conf file contains:

play.mailer {
  host=smtp.gmail.com
  port=465
  ssl=yes
  user="[email protected]"
  password=mypassword
}

And my method which sends the email contains:

    public Result madebyme(){
        Email email = new Email();
        email.setSubject("Welcome to my app");
        email.setFrom("My app<[email protected]");
        email.addTo("<[email protected]>");
        email.setBodyText("A text message");
        mailerClient.send(email);
        return ok();
    }

When sending from heroku I get the error:

2016-06-28T11:21:18.201681+00:00 app[web.1]: [error] application - 
2016-06-28T11:21:18.201715+00:00 app[web.1]:    at play.api.libs.mailer.MailerClient$class.send(MailerPlugin.scala:56)
2016-06-28T11:21:18.201729+00:00 app[web.1]:    at javax.mail.Transport.send(Transport.java:124)
2016-06-28T11:21:44.765639+00:00 app[web.1]:    at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
2016-06-28T11:21:44.765646+00:00 app[web.1]:    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
2016-06-28T11:21:44.765649+00:00 app[web.1]:    at play.api.libs.mailer.SMTPDynamicMailer.send(MailerPlugin.scala:117)
2016-06-28T11:21:44.765650+00:00 app[web.1]:    at play.api.libs.mailer.MailerClient$class.send(MailerPlugin.scala:56)
2016-06-28T11:21:44.765657+00:00 app[web.1]: 534-5.7.14  Learn more at
2016-06-28T11:21:44.765658+00:00 app[web.1]: 534 5.7.14  https://support.google.com/mail/answer/78754 bh4sm4680997wjc.43 - gsmtp
2016-06-28T11:21:44.765671+00:00 app[web.1]:    at org.apache.commons.mail.Email.send(Email.java:1448)
2016-06-28T11:22:04.966121+00:00 app[web.1]:    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
2016-06-28T11:22:04.966125+00:00 app[web.1]:    at play.api.libs.mailer.SMTPDynamicMailer.send(MailerPlugin.scala:117)
2016-06-28T11:22:04.966130+00:00 app[web.1]: 534-5.7.14 L7wRi827TVVn-_78HytiH4cAeTHWOYrvc1vdWF_7br_gcNB0JZDAEkfLZ8bpRu5ZqnhAjJ
2016-06-28T11:22:04.966131+00:00 app[web.1]: 534-5.7.14 oDf-9Fo-BDj3WOQqLkDd1L__bsSC72n-XzMKMIMS5cNHcNggAzZCWir6F6eu_2G4ChQopr
2016-06-28T11:22:04.966135+00:00 app[web.1]:    at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892)
2016-06-28T11:22:04.966140+00:00 app[web.1]:    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
2016-06-28T11:22:04.966141+00:00 app[web.1]:    at org.apache.commons.mail.Email.send(Email.java:1448)
@ggrossetie
Copy link
Member

Hello @johnmara I think you need to enable "less secure apps" on your Gmail account: https://www.google.com/settings/security/lesssecureapps

There's an open issue to be able to use a more secure authentication mechanism #97

@ggrossetie
Copy link
Member

ggrossetie commented Jun 28, 2016

You should also follow this guide to understand why the authentication failed: https://support.google.com/accounts/answer/6009563

In your case, you are trying to authenticate from a new location (Heroku).

@ggrossetie
Copy link
Member

@johnmara Is it working now ? Can I close this issue ?

@johnmara
Copy link
Author

Finally I used sendgrid and worked without a problem.

@ggrossetie
Copy link
Member

Ok so this is definitely related to a configuration issue with Gmail.
I'm closing this issue 😄

@Gex8
Copy link

Gex8 commented Aug 3, 2017

You have to check two important things when you want to send emails via Gmail smtp:

  1. Your apps configuration:
  • host: smtp.gmail.com
  • port: 587 or 465 (587 for tls, 465 for ssl)
  • protocol: tls or ssl
  • user: [email protected]
  • password: YOUR_PASSWORD
  1. The given Gmail account settings:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants