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"