Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-64095

Mail accounts with blank but non-null SMTP usernames erroneously fail validation

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • email-ext-plugin
    • Jenkins 2.249.2
      Email-Ext 2.78
    • 2.79

      Sending mails stopped working after upgrading from 2.76 to 2.78. The only messages I got were:

      [Pipeline] emailext
      21:28:39 Could not create session
      21:28:39 Could not create MimeMessage
      {{[Pipeline] }}}

      I now downgraded to 2.76 to make our intrastructure working again.

          [JENKINS-64095] Mail accounts with blank but non-null SMTP usernames erroneously fail validation

          Basil Crow added a comment - - edited
          1. Please provide the Pipeline code you are using to invoke the emailext step.
          2. Please provide a sanitized version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml (e.g., remove actual server names, usernames, passwords).
          3. Please provide a build log with debug mode enabled. Go to Manage Jenkins, click on Configure System, and in the Extended E-mail Notification section check Enable Debug Mode to enable debug mode for the Email Extension plugin. This will add additional log output to the build log for debugging purposes. Please remember to sanitize the build log before posting it here (e.g., remove actual email addresses, etc).
          4. While you're in the Configure System page, please verify that in the Jenkins Location section the System Admin e-mail address is set to a valid address and that the Admin Account Address is set to a valid address for each account in the Additional accounts subsection of the Extended E-mail Notification section (if any additional accounts are present).
          5. Please verify that for the default account and each account in the Additional accounts subsection of the Extended E-mail Notification section (if any additional accounts are present) that an SMTP server is set. Please also verify that the SMTP username is either blank or non-blank and accompanied by an SMTP Password.

          Basil Crow added a comment - - edited Please provide the Pipeline code you are using to invoke the emailext step. Please provide a sanitized version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml (e.g., remove actual server names, usernames, passwords). Please provide a build log with debug mode enabled. Go to Manage Jenkins, click on Configure System, and in the  Extended E-mail Notification section check Enable Debug Mode to enable debug mode for the Email Extension plugin. This will add additional log output to the build log for debugging purposes. Please remember to sanitize the build log before posting it here (e.g., remove actual email addresses, etc). While you're in the Configure System page, please verify that in the Jenkins Location section the System Admin e-mail address is set to a valid address and that the Admin Account Address is set to a valid address for each account in the Additional accounts subsection of the Extended E-mail Notification section (if any additional accounts are present). Please verify that for the default account and each account in the Additional accounts subsection of the Extended E-mail Notification section (if any additional accounts are present) that an SMTP server is set. Please also verify that the SMTP username is either blank or non-blank and accompanied by an SMTP Password .

          Basil Crow added a comment -

          This was almost certainly caused by jenkinsci/email-ext-plugin#217. To fix this I will almost certainly need what I requested in #2 above; namely, a sanitized version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml on a system that is exhibiting the problem. Please make sure the system is exhibiting the problem at the time you collect and send me ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml in order to facilitate proper diagnosis. It would also be helpful to know if you are using the default account or an additional account and what (if anything) you are passing in as the from parameter to the emailext step. One possible cause of the problem might be if smtpUsername is blank rather than unset (i.e., <smtpUsername></smtpUsername> appears rather than no entry existing in ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml). The relevant validation logic:

              public boolean isValid() {
                  return (isDefaultAccount() || StringUtils.isNotBlank(address)) && StringUtils.isNotBlank(smtpHost) && (!isAuth() || (StringUtils.isNotBlank(smtpUsername) && smtpPassword != null));
              }
          […]
              public boolean isAuth(){
                  return smtpUsername != null;
              }
          

          Basil Crow added a comment - This was almost certainly caused by jenkinsci/email-ext-plugin#217 . To fix this I will almost certainly need what I requested in #2 above; namely, a sanitized version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml on a system that is exhibiting the problem. Please make sure the system is exhibiting the problem at the time you collect and send me ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml in order to facilitate proper diagnosis. It would also be helpful to know if you are using the default account or an additional account and what (if anything) you are passing in as the from parameter to the emailext step. One possible cause of the problem might be if smtpUsername is blank rather than unset (i.e., <smtpUsername></smtpUsername> appears rather than no entry existing in ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml ). The relevant validation logic: public boolean isValid() { return (isDefaultAccount() || StringUtils.isNotBlank(address)) && StringUtils.isNotBlank(smtpHost) && (!isAuth() || (StringUtils.isNotBlank(smtpUsername) && smtpPassword != null )); } […] public boolean isAuth(){ return smtpUsername != null ; }

          Basil Crow added a comment -

          I opened jenkinsci/email-ext-plugin#258 to clean up the smtpUsername null check and add additional logging when Enable Debug Mode is enabled during mail account selection and mail account validation. Incremental build 2.79-rc1412.69bbd2a4562b is available for testing this change. The incremental build is available from: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/email-ext/2.79-rc1412.69bbd2a4562b/ For instructions on how to install a custom build, see: https://www.jenkins.io/doc/book/managing/plugins/#advanced-installation

          Basil Crow added a comment - I opened jenkinsci/email-ext-plugin#258 to clean up the smtpUsername null check and add additional logging when Enable Debug Mode is enabled during mail account selection and mail account validation. Incremental build 2.79-rc1412.69bbd2a4562b is available for testing this change. The incremental build is available from: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/email-ext/2.79-rc1412.69bbd2a4562b/ For instructions on how to install a custom build, see: https://www.jenkins.io/doc/book/managing/plugins/#advanced-installation

          Dave Kennedy added a comment -

          Same issue happened to me, i was able to unblock by unsetting the smtpUsername within ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml

          Dave Kennedy added a comment - Same issue happened to me, i was able to unblock by unsetting the smtpUsername within ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml

          basil I wanted to let you know that the fix in incremental build 2.79-rc1412.69bbd2a4562b fixed the issue for us, installed by uploading the hpi.

          Thomas Duboucher added a comment - basil I wanted to let you know that the fix in incremental build 2.79-rc1412.69bbd2a4562b fixed the issue for us, installed by uploading the hpi.

          Basil Crow added a comment -

          Same issue happened to me, i was able to unblock by unsetting the smtpUsername within ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml

          Thank you for confirming that the SMTP username was responsible for the mail account erroneously failing validation.

          I wanted to let you know that the fix in incremental build 2.79-rc1412.69bbd2a4562b fixed the issue for us, installed by uploading the hpi.

          Thank you for confirming that the fix in jenkinsci/email-ext-plugin#258 works.

          Basil Crow added a comment - Same issue happened to me, i was able to unblock by unsetting the smtpUsername within ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml Thank you for confirming that the SMTP username was responsible for the mail account erroneously failing validation. I wanted to let you know that the fix in incremental build 2.79-rc1412.69bbd2a4562b fixed the issue for us, installed by uploading the hpi. Thank you for confirming that the fix in jenkinsci/email-ext-plugin#258 works.

          Basil Crow added a comment -

          Released in 2.79.

          If any additional problems are encountered, please open a new Jira issue with the following information:

          1. A redacted version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml. Please remember to redact sensitive information from the configuration before posting it (e.g., remove actual server names, usernames, and passwords).
          2. A redacted build log with debug mode enabled. Go to Manage Jenkins, click on Configure System, and in the Extended E-mail Notification section check Enable Debug Mode to enable debug mode for the Email Extension plugin. This will add additional log output to the build log for debugging purposes. Please remember to redact the build log before posting it (e.g., remove actual email addresses, etc).

          Basil Crow added a comment - Released in 2.79 . If any additional problems are encountered, please open a new Jira issue with the following information: A redacted version of the <mailAccount/> and <addAccounts/> sections of ${JENKINS_HOME}/hudson.plugins.emailext.ExtendedEmailPublisher.xml . Please remember to redact sensitive information from the configuration before posting it (e.g., remove actual server names, usernames, and passwords). A redacted build log with debug mode enabled. Go to Manage Jenkins, click on Configure System, and in the Extended E-mail Notification section check Enable Debug Mode to enable debug mode for the Email Extension plugin. This will add additional log output to the build log for debugging purposes. Please remember to redact the build log before posting it (e.g., remove actual email addresses, etc).

          basil: Thank you very much for your quick response and addressing this issue. And thanks to Dave and Thomas for testing and confirming on the fix. You might also be interested to know that this problem (Silently not being able to send mails because smtpUsername field is not evaluated properly) now occurred at least twice (see https://issues.jenkins-ci.org/browse/JENKINS-63311); just in case this might be something that should be covered by a unit test (although I haven't check if a test already exists to cover the use case where no SMTP authentification is used).

           

          Manuel Leonhardt added a comment - basil : Thank you very much for your quick response and addressing this issue. And thanks to Dave and Thomas for testing and confirming on the fix. You might also be interested to know that this problem (Silently not being able to send mails because smtpUsername field is not evaluated properly) now occurred at least twice (see  https://issues.jenkins-ci.org/browse/JENKINS-63311 ); just in case this might be something that should be covered by a unit test (although I haven't check if a test already exists to cover the use case where no SMTP authentification is used).  

            basil Basil Crow
            skycaptain Manuel Leonhardt
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: