I'm trying to send a simple test email through SendGrid from my Java Play 2.10 application. I'm using the play-plugins-mailer to send the email and have a free (heroku) SendGrid account. This is everything I've done so far for:
- Added the play-plugins-mailer dependency to my Build.scala
- Added the CommonsMailerPlugin to my play.plugins file
Added the following code in my controller to send an email:
MailerAPI mail = play.Play.application().plugin(MailerPlugin.class).email(); mail.setSubject("test subject"); mail.addRecipient("[email protected]"); mail.addFrom("[email protected]"); mail.send("some text");Added the following in my application.conf:
smtp.host="smtp.sendgrid.net" smtp.user="[my-sendgrid-user]" smtp.pass="[my-sendgrid-pass]" smtp.port="587" smtp.channel=plain
I'm pretty sure the Mailer is working fine, it just seems to be a SendGrid configuration issue. When this code gets executed I get this error:
[RuntimeException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.sendgrid.net:587]
I've tried running this on my local machine as well as on heroku where I've added the SendGrid plugin to my app.