trying to send notification mails from my web site to myself using google smtp with phpmailer and I got to a point where I have a refresh token.
when I try to test the mail I get the following debug Error:
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP h6sm35172248paf.23 - gsmtp
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2001:569:78a5:aa00:8d54:17b8:c04b:1f31]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2001:569:78a5:aa00:8d54:17b8:c04b:1f31]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: AUTH XOAUTH2 dXNlcj1qYWNvYi5iYWxhYmFub3ZAZ21haWwuY29tAWF1dGg9QmVhcmVyIHlhMjkuQ2pIY0FneVhWcjlvdWVSUjRYN3o1aFhvYVFrRHROTDRONEwyd21DekpfTS1FWnpESWRQSHFlZlZTSEJTa3gwLXJDZ0oBAQ==
SERVER -> CLIENT: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
SMTP ERROR: AUTH command failed: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 h6sm35172248paf.23 - gsmtp
SMTP ERROR: QUIT command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 h6sm35172248paf.23 - gsmtp
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
string 'SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting' (length=82)
so I tried everything and I have no idea what to do...
Related
I'm going crazy with Yahoo and sending emails from an mail client with MailKit which manage tons of email but I'm cannot send to Yahoo only.
I tried to follow not only the MailKit documentation (https://github.com/jstedfast/MailKit/blob/master/FAQ.md#SslHandshakeException) but also the several posts found by googling which definitely advise me not to use the MX record of yahoo but to use authentication for third party apps and using a fixed params as mailserver, port and TLS
Despite this, I cannot deliver emails to valid yahoo addresses, and the behavior is very bizarre: if I connect without authentication, yahoo tells me "554 Email rejected", but if I connect with yahoo authentication it tells me "550 Request failed; Mailbox unavailable "when I receive tons of emails on the same email every day...I'm going to cry...
Here is the code and Yahoo's answer is there any good man to help me? Thank you so much in advance for your help, I have a very big problem with a customer.
Here the code used and the answers
WITH AUTHENTICATION
client.ServerCertificateValidationCallback = Function(s, c, h, e) True
client.CheckCertificateRevocation = False
client.Connect("smtp.mail.yahoo.com", 587, MailKit.Security.SecureSocketOptions.StartTls)
client.Authenticate(username, password)
Connected to smtp://smtp.mail.yahoo.com:587/?starttls=always
220 smtp.mail.yahoo.com ESMTP ready
EHLO mailsystem.xxxxx.xx
250-kubenode509.mail-prod1.omega.ir2.yahoo.com Hello mailsystem.xxxxx.xx [xxx.xxx.xxx.xxx])
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 41697280
250 STARTTLS
STARTTLS
220 2.0.0 Ready to start TLS
EHLO mailsystem.xxxxx.xx
250-kubenode509.mail-prod1.omega.ir2.yahoo.com Hello mailsystem.xxxxx.xx [xxx.xxx.xxx.xxx]])
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 41697280
250 AUTH PLAIN LOGIN XOAUTH2 OAUTHBEARER
AUTH PLAIN ********
235 2.7.0 Authentication successful
MAIL FROM:<no-reply#xxxxx.xx> SIZE=4892
RCPT TO:<xxxxxxxxxxxxxxx#yahoo.com>
550 Request failed; Mailbox unavailable
503 5.5.0 Need MAIL before RCPT
RSET
250 2.0.0 OK
WITHOUT AUTHENTICATION
client.ServerCertificateValidationCallback = Function(s, c, h, e) True
client.CheckCertificateRevocation = False
client.Connect("smtp.mail.yahoo.com", 587, MailKit.Security.SecureSocketOptions.StartTls)
Connected to smtp://smtp.mail.yahoo.com:587/?starttls=always
S: 220 smtp.mail.yahoo.com ESMTP ready
C: EHLO mailsystem.xxxxx.xx
S: 250-kubenode503.mail-prod1.omega.ir2.yahoo.com Hello mailsystem.xxxxx.xx [xxx.xxx.xxx.xxx]])
S: 250-PIPELINING
S: 250-ENHANCEDSTATUSCODES
S: 250-8BITMIME
S: 250-SIZE 41697280
S: 250 STARTTLS
C: STARTTLS
S: 220 2.0.0 Ready to start TLS
C: EHLO mailsystem.xxxxx.xx
S: 250-kubenode503.mail-prod1.omega.ir2.yahoo.com Hello mailsystem.xxxxx.xx [xxx.xxx.xxx.xxx]])
S: 250-PIPELINING
S: 250-ENHANCEDSTATUSCODES
S: 250-8BITMIME
S: 250-SIZE 41697280
S: 250 AUTH PLAIN LOGIN XOAUTH2 OAUTHBEARER
C: MAIL FROM:<no-reply#xxxxx.xx> SIZE=4892
C: RCPT TO:<xxxxxxxxxxxxxxx#yahoo.com>
S: 554 Email rejected
S: 503 5.5.0 Need MAIL before RCPT
C: RSET
S: 250 2.0.0 OK
The problem is your use of the no-reply#address.com. You need to use your yahoo mail address.
I'm working with a desktop application, trying to develop a function to allow application users sending out emails using their GMAIL account.
I've created client ID, secret and set up consent screen for my application. The token was got successfully. But when I try to login using this token, the following error happens:
SmtpCmdResp: 334
Failed to login using XOAUTH2 method
The complete mailing log is like the following:
ChilkatLog:
SendEmail:
DllDate: Sep 28 2020
ChilkatVersion: 9.5.0.84
UnlockPrefix: Auto unlock for 30-day trial
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
Component successfully unlocked using trial key
sendEmailInner:
renderToMime_pt1:
createEmailForSending:
Auto-generating Message-ID
--createEmailForSending
--renderToMime_pt1
sendMimeInner:
ensureSmtpSession:
ensureSmtpConnection:
smtpParams:
SmtpHost: smtp.gmail.com
SmtpPort: 587
SmtpUsername: xxxxx#gmail.com
SmtpSsl: 0
StartTLS: 1
--smtpParams
smtpConnect:
smtpHostname: smtp.gmail.com
smtpPort: 587
connectionIsReady:
Need new SMTP connection
--connectionIsReady
smtpSocketConnect:
socketOptions:
SO_SNDBUF: 262144
SO_RCVBUF: 4194304
TCP_NODELAY: 1
SO_KEEPALIVE: 1
--socketOptions
--smtpSocketConnect
smtpGreeting:
readSmtpResponse:
SmtpCmdResp: 220 smtp.gmail.com ESMTP z20sm6231415qtb.31 - gsmtp
--readSmtpResponse
--smtpGreeting
startTLS:
sendCmdToSmtp:
SmtpCmdSent: EHLO xxxxxxxxx<CRLF>
--sendCmdToSmtp
readSmtpResponse:
SmtpCmdResp: 250-smtp.gmail.com at your service, [198.52.156.138]
SmtpCmdResp: 250-SIZE 35882577
SmtpCmdResp: 250-8BITMIME
SmtpCmdResp: 250-STARTTLS
SmtpCmdResp: 250-ENHANCEDSTATUSCODES
SmtpCmdResp: 250-PIPELINING
SmtpCmdResp: 250-CHUNKING
SmtpCmdResp: 250 SMTPUTF8
--readSmtpResponse
sendCmdToSmtp:
SmtpCmdSent: STARTTLS<CRLF>
--sendCmdToSmtp
readSmtpResponse:
SmtpCmdResp: 220 2.0.0 Ready to start TLS
--readSmtpResponse
TLS connection established.
--startTLS
ehloCommand:
sendCmdToSmtp:
SmtpCmdSent: EHLO xxxxxxxxx<CRLF>
--sendCmdToSmtp
readSmtpResponse:
SmtpCmdResp: 250-smtp.gmail.com at your service, [198.52.156.138]
SmtpCmdResp: 250-SIZE 35882577
SmtpCmdResp: 250-8BITMIME
SmtpCmdResp: 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
SmtpCmdResp: 250-ENHANCEDSTATUSCODES
SmtpCmdResp: 250-PIPELINING
SmtpCmdResp: 250-CHUNKING
SmtpCmdResp: 250 SMTPUTF8
--readSmtpResponse
--ehloCommand
--smtpConnect
--ensureSmtpConnection
ensureSmtpAuthenticated:
smtpAuthenticate:
smtp_host: smtp.gmail.com
smtp_port: 587
smtp_user: xxxxx#gmail.com
smtpAuthenticate:
login_method: XOAUTH2
auth_xoauth2:
username: xxxxx#gmail.com
sendCmdToSmtp:
SmtpCmdSent: {PasswordOrCredentials}
--sendCmdToSmtp
readSmtpResponse:
SmtpCmdResp: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
--readSmtpResponse
--auth_xoauth2
Failed to login using XOAUTH2 method
--smtpAuthenticate
ConnectionType: SSL/TLS
--smtpAuthenticate
--ensureSmtpAuthenticated
--ensureSmtpSession
--sendMimeInner
--sendEmailInner
Failed.
--SendEmail
--ChilkatLog
I was using PoweBuilder as the development language and this log is from a third party OCX control named Chilkat. Note that I've replaced the computer name and my testing Gmail account user name with "x". Other parts are kept original. The token was saved to a file located at local hard drive and then got read and used.
Does any one know if the login failure is because of my application is not validated by Google yet? Or it just indicates that the token was not valid, or something else.
Thanks in advance.
OK. Reason was found. It's because of the scope defined when trying to get the token did not include "https://mail.google.com".
The clue is in the line of 334 response code. Decoding the base64 string after "SmtpCmdResp: 334", it is actually {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}.
I then search for this string in Google and found out that this means the scope of "https://mail.google.com" was not included when trying to get the token. When I include this scope in my PowerBuilder code, I could send out email successfully.
This makes me feel bad. The scope "https://mail.google.com/" means that user need to consent all the permissions about his/her Gmail account to the application. But what the application needs was just to represent the user to login to Gmail SMTP Server and send out email(s) on his/her behalf. The application does not need to have access to anything else like what email(s) has been sent out, or who's in the address book, or what's in the inbox. To tell the truth, I was thinking of clicking "No" when I test out this function and the consent page tells me that I need permit everything.
I've been trying for weeks to get to configure rundeck to send emails using my gmail smtp settings on a Centos7 vm. I do have an ssl cert (that I purchased) configured for the server. Not sure if that has something to do with it. So far I have:
Converted the "/etc/rundeck/rundeck-config.properties" file to
"/etc/rundeck/rundeck-config.groovy" file
Updates the "/etc/sysconfig/rundeckd" file with the following settings. "export RUNDECK_WITH_SSL=true
export RDECK_CONFIG_FILE="/etc/rundeck/rundeck-config.groovy"
Edited my "/etc/rundeck/rundeck-config.groovy" with the following text.
loglevel.default="INFO"
rdeck.base="/var/lib/rundeck"
rss.enabled=false
grails.mail.default.from="user#gmail.com"
dataSource.dbCreate = "update"
dataSource.url = "jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true;TRACE_LEVEL_FILE=4"
grails {
mail {
host = "smtp.gmail.com"
username = "user#gmail.com"
port = 465
password = "password"
props = ["mail.smtp.auth":"true",
"mail.smtp.port":"465",
"mail.smtp.starttls.enable":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.fallback":"false"]
}
}
grails.serverURL="https://rundeck-server:4443"
rundeck.log4j.config.file = "/etc/rundeck/log4j.properties"
If I run it with port 465, I receive the following error.
2019-01-03 14:57:26.260 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService : Error sending notification email to user#gmail.com for Execution 231: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
If I configure using port 587, I receive the following error in the "/var/log/rundeck/service.log"
2019-01-03 15:05:52.121 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService : Error sending notification email to user#gmail.com for Execution 233: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Failed messages: javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Alternatively, I installed mailx and although theres an error in the logs, it successfully sends an email when I run the following "echo "Your message" | mail -v -s "Message Subject" user#gmail.com" command. The output is
Resolving host smtp.gmail.com . . . done.
Connecting to x.x.x.x:465 . . . connected.
Error in certificate: Peer's certificate issuer is not recognized.
Comparing DNS name: "smtp.gmail.com"
SSL parameters: cipher=AES-xxx-GCM, keysize=xxx, secretkeysize=xxx,
issuer=CN=Google Internet Authority G3,O=Google Trust Services,C=US
subject=CN=smtp.gmail.com,O=Google LLC,L=Mountain View,ST=California,C=US
220 smtp.gmail.com ESMTP b22sm9658588ios.45 - gsmtp
>>> EHLO rundeck-server
250-smtp.gmail.com at your service, [x.x.x.x]
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 xxxx
>>> xxxx==
334 xxxx
>>> xxxx==
235 2.7.0 Accepted
>>> MAIL FROM:<user#rundeck-server>
250 2.1.0 OK xx - gsmtp
>>> RCPT TO:<user#gmail.com>
250 2.1.5 OK xx - gsmtp
>>> DATA
354 Go ahead xx - gsmtp
>>> .
250 2.0.0 OK xx - gsmtp
>>> QUIT
221 2.0.0 closing connection xx - gsmtp
I added the following to the bottom of my "/etc/mail.rc" file
set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=USER.GMAIL.COM
set smtp-auth-password='password'
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
Looks like you're using a self-signed certificate or non trusted certificate by google, check that:
Related links:
Java: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
http://web.archive.org/web/20080820101722/http://blogs.sun.com/andreas/entry/no_more_unable_to_find
https://news.ycombinator.com/item?id=4920088
http://code.naishe.in/2011/07/looks-like-article-no-more-unable-to.html
I send emails from my gmail account with these settings in /etc/rundeck/rundeck-config.groovy
grails {
mail {
host = "smtp.gmail.com"
username = "USER"
port = 587
password = "PASSWORD"
props = ["mail.smtp.starttls.enable":"true","mail.smtp.auth":"true","mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"]
}
}
Specifically we fail with this message:
[30-Apr-2017 14:05:18 UTC] PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in /home/xxxxxxxx/public_html/phpmailer/PHPMailer-5.2.8/class.smtp.php on line 272
Googling this we find reports of similar errors during upgrades from PHP 5.5 - but these all stem from improved certificate verification introduced in PHP 5.6. This doesnt seem to be our issue. For instance - following the PHPMailer troubleshooting wiki - we are able to connect to the smtp server with openSSL.
openssl s_client -starttls smtp -crlf -connect vps.ourserver.com:587
.
.
SSL handshake has read 5284 bytes and written 468 bytes
.
.
Verify return code: 0 (ok)
Turning SMTBDebug on (level 4) doesn't really show anything useful:
2017-04-30 16:04:54 CLIENT -> SERVER: STARTTLS
2017-04-30 16:04:54 SMTP -> get_lines(): $data is ""
2017-04-30 16:04:54 SMTP -> get_lines(): $str is "220 TLS go ahead
"
2017-04-30 16:04:54 SERVER -> CLIENT: 220 TLS go ahead
2017-04-30 16:04:54 SMTP Error: Could not connect to SMTP host.
2017-04-30 16:04:54 CLIENT -> SERVER: QUIT
As stated - this problem started immediately after the PHP upgrade. No changes to code or SSL/Certificate configurations.
Suggestions on next steps to troubleshoot?
Edit: It was suggested that this question may have been solved previously SSL3_GET_SERVER_CERTIFICATE.. but it is a different error message (and I did try overriding the smtpoptions as suggested - to no effect).
Solved.
Upgraded to PHPMailer 5.2.23 and the error message disappeared. Thanks to Synchro (despite the snarky tone...lol).
Whilst trying to send email using GMAIL on the PDI job, I face a connection timed out error.
Settings were as give below
SMTP ->smtp.gmail.com
Port -> 465 (also tried with 587 and 25)
And followed by SSL connection with my full credentials.
This is the error I am getting
2016/08/24 11:56:48 - Mail - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Problem while sending message: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
I see a similar open question here but with little help
Any help?
by using below server configuration i used to send mail from PDI
1.SMTP ->smtp.gmail.com
2.Port -> 465
3. use authentication [check this]
4.authentication user (use your gmail id)
5.authentication password (use your gmail password)
6.use secure authentication
7. secure connection type = SSL
when this job will execute in your gmail account a security concern mail will be sent by gmail team and you need to allow that security check