This topic is locked

Troubleshooting SMTP errors

7/14/2022 5:21:51 PM
PHPRunner Tips and Tricks
Sergey Kornilov

Version 10.8 makes troubleshooting email sending issues easier. By default, SMTP error messages are crypric and in most cases you will see something like this:
SMTP Error: Could not authenticate

Now, it version 10.8, if you enable debug mode as shown in Troubleshooting technique article.

$dDebug = true;

Once the debug mode is enabled we can see something like this:

2022-07-14 17:19:54 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()
2022-07-14 17:19:54 Connection: opened
2022-07-14 17:19:54 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp"
2022-07-14 17:19:54 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp
2022-07-14 17:19:54 CLIENT -> SERVER: EHLO localhost
2022-07-14 17:19:54 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [71.163.165.233]"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-SIZE 35882577"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-8BITMIME"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-PIPELINING"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250-CHUNKING"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "250 SMTPUTF8"
2022-07-14 17:19:54 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [71.163.165.233]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2022-07-14 17:19:54 Auth method requested: UNKNOWN
2022-07-14 17:19:54 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
2022-07-14 17:19:54 Auth method selected: LOGIN
2022-07-14 17:19:54 CLIENT -> SERVER: AUTH LOGIN
2022-07-14 17:19:54 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6"
2022-07-14 17:19:54 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2022-07-14 17:19:54 CLIENT -> SERVER: c3VwcG9ydEB4bGluZXNvZnQuY29t
2022-07-14 17:19:54 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6"
2022-07-14 17:19:54 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2022-07-14 17:19:54 CLIENT -> SERVER: bGtlZV45MzRsSGQx
2022-07-14 17:19:54 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "535-5.7.8 Username and Password not accepted. Learn more at"
2022-07-14 17:19:54 SMTP -> get_lines(): $data is "535-5.7.8 Username and Password not accepted. Learn more at"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "535 5.7.8 https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp"
2022-07-14 17:19:54 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp
2022-07-14 17:19:54 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp
SMTP Error: Could not authenticate.
2022-07-14 17:19:54 CLIENT -> SERVER: QUIT
2022-07-14 17:19:55 SMTP -> get_lines(): $data is ""
2022-07-14 17:19:55 SMTP -> get_lines(): $str is "221 2.0.0 closing connection de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp"
2022-07-14 17:19:55 SERVER -> CLIENT: 221 2.0.0 closing connection de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp
2022-07-14 17:19:55 Connection: closed
SMTP Error: Could not authenticate.

Now, while this may look overwhelming, it tells use that username/password combination is incorrect:

2022-07-14 17:19:54 SMTP -> get_lines(): $data is "535-5.7.8 Username and Password not accepted. Learn more at"
2022-07-14 17:19:54 SMTP -> get_lines(): $str is "535 5.7.8 https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials'>https://support.google.com/mail/?p=BadCredentials de32-20020a05620a372000b006b58d8f6181sm1808539qkb.72 - gsmtp"
N
nkuru007 11/16/2022

I have the same error but the username and password are correct, i tried using yahoo also but in vain. What could be the problem

Below are last lines in the debug:

2022-11-16 14:09:09 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials g18-20020a05600c4ed200b003cf6e1df4a8sm2682100wmq.15 - gsmtp
SMTP Error: Could not authenticate.
2022-11-16 14:09:09 CLIENT -> SERVER: QUIT
2022-11-16 14:09:09 SMTP -> get_lines(): $data is ""
2022-11-16 14:09:09 SMTP -> get_lines(): $str is "221 2.0.0 closing connection g18-20020a05600c4ed200b003cf6e1df4a8sm2682100wmq.15 - gsmtp"
2022-11-16 14:09:09 SERVER -> CLIENT: 221 2.0.0 closing connection g18-20020a05600c4ed200b003cf6e1df4a8sm2682100wmq.15 - gsmtp
2022-11-16 14:09:09 Connection: closed
SMTP Error: Could not authenticate.
SELECT * FROM permission_ugrights WHERE ( ( ( GroupID IN ( -3 ) ) and ( NOT ( AccessMask is null or AccessMask = '' ) ) ) )

br.
Clement

Sergey Kornilov 11/16/2022

It specifically says Username and Password are not accepted.

Did you check the link for more details? Google's error messages can be cryptic.
https://support.google.com/mail/?p=BadCredentials

Also check A COMPLETE GUIDE TO SENDING EMAILS WITH A WEB-BASED APPLICATION article

Dalkeith 11/17/2022

I've had one user that had issues with the logging in.

Steps I followed where
lower case the email in the database table ensure no trailing or leading spaces.

Ensure when they get the reminder email which in my case gave them their username and password that they type it in manually as there seemed to be issues with cut and paste between windows..