im trying to send email with mail plugin in grails with the gmail account.
The email is sent successfully but i have a problem with the sender of the email
In Config.groovy
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "myacount@gmail.com"
password = "mypassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Then from my app, i call
mailService.sendMail {
to "another@gmail.com"
from "sender@gmail.com"
subject sub
body message
}
The email is sent fine to another@gmail.com, but the sender is not the sender@gmail.com but the myaccount@gmail.com. Any advice?
You can’t do this in on GMail. It forces you to use the “myaccount@gmail.com”, you’ll need to either use a local provide, another provider all together or accept “myaccount@gmail.com”.
I believe this is done on purpose to prevent people from sending spam through Gmail.