Grails mail plugin works locally but fails on server - email

I can't get the mail plugin for Grails to work properly on production server with the suggestions out there (such as checking for different versions of plugins)
With the same configuration it works in my local environment.
This is my Config.groovy
grails {
// other configs
mail {
host = "smtp.gmail.com"
port = 465
username = "xxx#gmail.com"
password = "secret"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
} ...
}
EDIT:
This is the exception thrown:
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is
javax.mail.AuthenticationFailedException:
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvYY
534-5.7.14 rIXXHBxKKMt9ftNn9GuoppiRgCLMYf1-L3FM15F0yD0nZ_8AKpbuqjHm-6Jm7VBn8NluX9
534-5.7.14 gJki2Giv7aWaflq3L1Vo7uZYIn_v7z1eLe51jbb2UawpOmwdzJLMDvbypH6WW3LyC80pUI
534-5.7.14 3jm1omeGD_E-BecER_IGa7f4FsN1HMpRRIYRfPgxX_X0yZ276KrPvXR9t0eNqZ-XfF4Wp8
534-5.7.14 WtEuhDF7ms_YZh25KdmFjuEwY8v0> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 q41sm10613096qkq.4 - gsmtp
I know what mailAuthenticationException means, but this works perfectly on local environment, so it's not user/pass data, and the email was configured to allow less secure access on Gmail account. So there should be something wrong in the code.
Im using mail:1.0.7 and grails 2.4.4.
P.D.: I will try on commons email of apache and see what happens...

Related

Classis ASP sending to smtp.gmail.com doesn't work

I need to send email from my server to smtp.gmail.com using classic ASP.
I am using the ASPEmail component and have the latest version (5.4.0.6) aspemail64.
Everything I try gives an error.
1) Just user and password
mailer.host = "smtp.gmail.com"
mailer.Username = "someone#somewhere.org"
mailer.Password = "somepass"
This gives:
Err = 530 5.7.0 Must issue a STARTTLS command first.
2) TLS and port 587
mailer.TLS = True
mailer.Port = 587
Transport Layer Security Error #30 (SMTP): 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
3) SSL and port 465
mailer.SSL = True
mailer.Port = 465
Transport Layer Security Error #30 (SMTP): 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
Anyone get Classic ASPEmail64 working with smtp.gmail.com?
Thanks for the answers.
I got this figured out and this information may help someone else.
You have to have a SPF record in your DNS.
https://en.wikipedia.org/wiki/Sender_Policy_Framework
Once I put that in all the weird errors went away even with the gmail security setting turned back on.
It works now with the latest ASPEmail64 and these settings.
mailer.From = "someone#somewhere.com"
mailer.Username = "someone#somewhere.com"
mailer.Password = "password"
mailer.host = "smtp.gmail.com"
mailer.TLS = True
mailer.Port = 587

Sending Mail via Gmail Stopped

Our system was sending emails fine just until now.
I'm getting the following response. Can anyone help?
The error seems to be related to authentication, but password hasn't changed. Any advise would be appreciated.
220 smtp.gmail.com ESMTP a21sm25596087pfj.40 - gsmtp
EHLO rd00155d50d7af.domain
250-smtp.gmail.com at your service, [137.117.9.62]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
AUTH LOGIN
334 VXNlcm5hbWU6
c3VwcG9ydEBiaWxsaXZpbmcuY29t
334 UGFzc3dvcmQ6
amJqYjEyMzQ=
<> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 a21sm25596087pfj.40 - gsmtp
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbu3x
534-5.7.14 qqwDxkeiCBe55evYz8U5pozdCeuEWMf1echBlK4Ykmdot0LTgv1bDDQ_jnMs8GkFyw_ZAq
534-5.7.14 rmojkAJQAXfzRevQObN8MhH8hmMSCtMMmVJsuX5z805SazSchBKmytkfBbrjWalI6rTnix
534-5.7.14 z9_glL258Wjln_nWvFNhNevdanJ3CuUIsj9aRpExjUkygsDrQFixW-DeqU9pLzrsekK7uz
534-5.7.14 b8zCWUHGgSUYrxNb4M_kxWIEsuyk> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 a21sm25596087pfj.40 - gsmtp
Google blocked your ability to send mail until you verify your account. Visit the url contained in the error message to unlock your account. i.e. https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbu3xqqwDxkeiCBe55evYz8U5pozdCeuEWMf1echBlK4Ykmdot0LTgv1bDDQ_jnMs8GkFyw_ZAqrmojkAJQAXfzRevQObN8MhH8hmMSCtMMmVJsuX5z805SazSchBKmytkfBbrjWalI6rTnixz9_glL258Wjln_nWvFNhNevdanJ3CuUIsj9aRpExjUkygsDrQFixW-DeqU9pLzrsekK7uzb8zCWUHGgSUYrxNb4M_kxWIEsuyk
Turns out you need to allow less secure password or use App password. Alternatively, one can use Gmail OAuth. Google must have just changed its behavior.

gmail for work cannot send email with SMTP

I am trying to send email to another email address..
my code run well if i am using this as my email server.
grails {
mail{
// teravin smtp setting
host = "smtp.gmail.com"
port = 465
username = "myname#gmail.com"
password = "ping123456"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.starttls.enable": "true",
"mail.smtp.socketFactory.fallback":"false"]
}
}
but i tried to using Gmail For Work like this
grails {
mail{
// teravin smtp setting
host = "smtp.gmail.com"
port = 465
username = "myname#mydomain.com" //here i am using a domain. like dwayne#alibaba.com
password = "ping123456"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.starttls.enable": "true",
"mail.smtp.socketFactory.fallback":"false"]
}
}
then i get an error like this..
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbu7
A
534-5.7.14 Armc1Kv6BMKJgBgDa5JMjBolFfZ-IxR1po773uTSasXpJcLSemxn58swxGL_3zIOhnNVF
N
534-5.7.14 5g0y20MA6FFEVrE_xzqcpS3SooMYLpr2_WWtgnNBSZi4Ycnq1SrGv-rqZ50fnOA8GPLdp
I
534-5.7.14 15howBb6bqYod_AsiKgjkfKGXK1z1F_0u79m3UmYfQXAjnai49pMz5GZkvp6oDYxEClM3
x
534-5.7.14 1CmWME6Jbkph6tVkdGd-yjlHow9c> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 f21sm1805436pfd.6 - gsm
tp
. Stacktrace follows:
Message: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt
=AKgnsbu7A
534-5.7.14 Armc1Kv6BMKJgBgDa5JMjBolFfZ-IxR1po773uTSasXpJcLSemxn58swxGL_3zIOhnNVF
N
534-5.7.14 5g0y20MA6FFEVrE_xzqcpS3SooMYLpr2_WWtgnNBSZi4Ycnq1SrGv-rqZ50fnOA8GPLdp
I
534-5.7.14 15howBb6bqYod_AsiKgjkfKGXK1z1F_0u79m3UmYfQXAjnai49pMz5GZkvp6oDYxEClM3
x
534-5.7.14 1CmWME6Jbkph6tVkdGd-yjlHow9c> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 f21sm1805436pfd.6 - gsm
tp
i wonder why i get this error...is this because i still using trial account ?
A clue to your solution lies in the error message specifically,
https://support.google.com/mail/answer/78754
Try following the "Troubleshoot" section there.
I've had this problem before and solved it using one of these steps mentioned in that page:
Sign in to your account from the web version of Gmail at
https://mail.google.com. Once you’re signed in, try signing in to the
mail app again.
Visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in
with your Gmail username and password. If asked, enter the letters in
the distorted picture.

How do you fix 550 must be authenticated sending Mail using Grails?

I'm using Grails Mail plugin and trying to send email and keep getting:
Error 500: Executing action [sendInvite] of controller
[RegisterController] caused exception: Failed messages:
javax.mail.SendFailedException: Invalid Addresses; nested exception
is: com.sun.mail.smtp.SMTPAddressFailedException: 550 must be
authenticated
I'm properly following the instructions at: http://www.grails.org/Mail+plugin
The mail server is returning an error when you try to send out the mail. 550 is a generic SMTP failure code; in this case it looks like you are missing a username and password. Some SMTP servers to not require authentication but most do, especially if they're publicly available on the internet. It's also possible that your SMTP server requires an SSL connection and you're connecting with an unsecured socket.
The example config for gmail shows how to set all the mail server authentication options in Config.groovy:
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "youracount#gmail.com"
password = "yourpassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Add "mail.debug": "true" to props to turn on JavaMail debugging to get a better picture of what is happening before the failure.
In my case the 550 error was caused by me having accidentally selected and IMAP account as the default account but sending emails from my Outlook Connector Account (which has no authentication settings to make).
I changed the Outlook Connector Account to default. Resent the emails and no errors.
So check that the correct email account is set up as the default also

Gmail smtp SASL authentication

I'm using postfix to send email via gmail with an application's password (two step-validation activated).
Each time I test sending mail using sendmail command, I get this error:
Action: delayed
Status: 4.7.14
Diagnostic-Code: X-Postfix; delivery temporarily suspended: SASL authentication
failed; server smtp.gmail.com said: 534-5.7.14
<https://accounts.google.com/signin/continue?...> Please log in via your web browser and?534-5.7.14 then try again.?534-5.7.14
This is my postfix configuration:
main.cf
myorigin = /etc/mailname
mydestination = mydomain.com, localhost.fr, localhost
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
/etc/postfix/sasl/sasl_passwd:
[smtp.gmail.com]:587 admin#mydomain.com:application_password
And this is how I used sendmail:
sendmail -v ...
From: admin#mydomain.com
Subject: Test
This is a test mail
.
Any ideas ? Thanks !
For anyone finding this who has run into the same scenario:
Using an app specific password
2FA enabled on your account
Seeing 'delivery temporarily suspended: SASL authentication failed; server smtp.gmail.com[173.194.68.109] said: 534-5.7.9 Please log in with your web browser and then try again' in your log
You may need to visit https://accounts.google.com/DisplayUnlockCaptcha to 'bypass' the captcha, which will enable the account access and get everything working.
Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.