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

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

Related

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.

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

SMTP authentication failure while using SendGrid/Gmail

I am getting SMTP Authentication Failure on the server and the mail is getting send via the server SMTP only...
It appears to be a server configuration or related problem, but I am not sure.
This is the debug details:
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
Failed to authenticate password. Error: 535 Incorrect authentication data
from: 250 OK
to: 250 Accepted
data: 354 Enter message, ending with "." on a line by itself
250 OK id=1U8Pjp-0002As-FB
quit: 221 ************** closing connection
Your message has been successfully sent using the following protocol: smtp
While testing from my local system, this works and the email is being sent via sendgrid.me
Again, This may not be a SendGrid Problem, but if you have faced similar issue, Can you please tell me what is the problem here?
I am using CentOs and I have cPanel in the server. I believe we are using EXIM for mail server.
For anyone that comes across this in future and are using cpanel/whm, you need to 'disable' this option under 'SMTP Restrictions' in WHM.
I was able to resolve this.
The issue was my server was not allowing the use of external SMTP and using its own SMTP server. I changed the settings and now it works fine.
I am using centos 7 Finally it works!
I was getting this issue(tail -f /var/log/mailog):
to=<usmanali#example.com>, relay=smtp.sendgrid.net[169.45.113.201]:587, delay=0.3, delays=0.05/0.07/0.16/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[169.45.113.201] said: 550 Unauthenticated senders not allowed (in reply to MAIL FROM command))
Then i changed file /etc/postfix/main.cf in this way that added following lines into end of file
mtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 256000000
# Sendgrid Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:SG.YOUR_SENDGRID_KEY
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
Then Installing postfix missing module dependency using:
sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
Then restarting postfix
sudo systemctl restart postfix.service