I have the same issue. My Jenkins is linked to my GMAIL account with 2-factor authentication. I added an App Password for Jenkins via Gmail, updated the global configs, and ran the test email. The test email ran properly without issue. The email was sent to the recipient and it was in my google email sent box. When I ran it in my code.
stages{
stage('Testing Email'){
steps
{
emailext body: 'Just a test', subject: 'Testing', to: 'email@gmail.com'
}
//end steps
} //end stage
I get the following error. How can it work with the same setup in the test but fail in the code. It's as if the pipeline text was updated but not the site. Or the configs aren't sending the updated password. I also tried uninstalling & reinstalling and disabling & enabling.
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: STARTTLS requested but already using SSL
DEBUG SMTP: protocolConnect login, host=smtp.gmail.com, user=email@gmail.com, password=<non-null>
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM XOAUTH2
DEBUG SMTP: Using mechanism LOGIN
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
AuthenticationFailedException message: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials d64-20020a37b443000000b0073b587194d0sm9710612qkf.104 - gsmtp
You'll need to provide much more information before others will be able to provide you any guidance. Please provide the information as noted in "How to report an issue" in hopes that will allow others to understand and investigate the issue.