issue with play-easymail while using play framework 2.2
-
21-12-2019 - |
Question
I am using the conf below for sending emails out in play v2.2 via play-easymail - I do not see any exception thrown in my code & I have tried both a local SMTP server as well as as the SMTP service from gmail. I have not been able to receive the email (its not in any junk email folder). Any suggestions on troubleshooting this (besides checking the local SMTP server logs) will be appreciated. The SMTP config is imported via the application.config file.
conf
# SMTP mailer settings
smtp {
# enable mocking - disable this for production
mock=true
# SMTP server
# (mandatory)
# defaults to gmail
host=smtp.gmail.com
# SMTP port
# defaults to 25
port=587
# Use SSL
# for GMail, this should be set to true
ssl=true
#tls=true
# authentication user
# Optional, comment this line if no auth
# defaults to no auth
user=correctEmail@gmail.com"
# authentication password
# Optional, comment this line to leave password blank
# defaults to no password (or use (two way) hash the pwd and get the pwd from the two way hash)
password=correctPwd
}
test code
import com.feth.play.module.mail.Mailer;
import com.feth.play.module.mail.Mailer.Mail.Body;
//email method: emailAddress passed is correct
try {
final Body body = new Body("test email");
Mailer.getDefaultMailer().sendMail("metrics email | it works!",
body, emailAddress);
}
catch (Exception e) {
Logger.info("exception while sending email {}", e);
e.printStackTrace();
}
Solution
it was pilot error. I had to set mock equal to false in the conf file. I was able to send emails after this change.
mock=false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow