gmail for work cannot send email with SMTP - email

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.

Related

smtp error: 534 when sending email through gmail in golang app

On my golang app I use this snippet to send email from my gmail account:
func send(body string) {
from := "myaccount#gmail.com"
pass := "mysupersecretpasswd"
to := "whoever#whatever.com"
msg := "From: " + from + "\n" +
"To: " + to + "\n" +
"Subject: Hello there\n\n" +
body
err := smtp.SendMail("smtp.gmail.com:587",
smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
from, []string{to}, []byte(msg))
if err != nil {
log.Printf("smtp error: %s", err)
return
}
log.Print("sent, visit whatever)
}
I get this error instead:
smtp error: 534 5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbud
5.7.14 lxVDnr-tXOckmxXi0fxExY5BKDRczBpGvMCpGWGF97jAI5DlM2oeGMDcIkvBhKT9rJAVnH
5.7.14 WP7zxssynLtkzMb35et-wxJF2AfeBhMA81QqMh2F8fkQRdf9GidA3swFnjfsUl0Pw6fiMT
5.7.14 b3zvEJyD6WAKEWcuxEGJIBTaqCtfDjipQ58cFJweUiKg1_4AJp0fGpC9ufnjBGWqWVKeW9
5.7.14 QVbUstROYK0SzjWXTTvsvZhhG3RjM> Please log in via your web browser and
5.7.14 then try again.
5.7.14 Learn more at
5.7.14 https://support.google.com/mail/answer/78754 61sm6182123wre.44 - gsmtp
I have installed postfix on my localhost. I have also allowed less secure apps to access my account.
I have also tried the same code on my VPS, but it does not send emails either.
So what could be wrong? How can I fix it?
I've copied your gist, replaced from, to and password and it works flawlessly. The only reason why this code is not working is that you are NOT allowing less secure apps in gmail.

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.

Grails mail plugin works locally but fails on server

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...

Send email from gmail using Telnet

I am working on windows and I have enabled telnet client
In cmd prompt:
$telnet smtp.gmail.com 587
220 mx.google.com ESMTP dk3sm50678627pbc.32 - gsmtp
$Helo
250 mx.google.com at your service
$ mail from: <myuser#gmail.com>
530 5.7.0 Must issue a STARTTLS command first. dk3sm50678627pbc.32 - gsmtp
$ STARTTLS
220 2.0.0 Ready to start TLS
$ mail from:
C:\Users\{myuser}>
Connection to host lost.
Don't know What is the problem ?
Can anyone help me out , how i can send emails from gmail server using telnet from command line >
smtp.gmail.com requires TLS. The basic telnet client that comes with windows does not know how to negotiate TLS with a server. You may want to use openssl instead, which is able to negotiate TLS. See http://www.madboa.com/geek/openssl/#cs-smtp for an example of how to do this.
The gmail smtp must use smtp auth before you sending your email. The smtp auth need username and password.
see this link blow if you can read in Chinese.
http://linxucn.blog.51cto.com/1360306/837365
Last I sugguest you use java to ask gmail smtp server to send email, It will be more easy , becasue you needn't encode the smtp auth to BASE64 or anything else.
GOGOGO, good luck :)
Put into a VBS file, ie sendmail.vbs.
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "cat#gmail.com"
emailObj.To = "cat#gmail.com"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
emailObj.AddAttachment "c:\windows\win.ini"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "cat"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Ccat1"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"
At Google's web site for GMail you have to turn this feature on for CDO to work.
At your Gmail page click Settings - Accounts and Import - Other Google Account Settings - [At very bottom of page] Allow less secure apps.
Also from memory you also have to click a link in an email the first time you use it (it's been a few years).