Uploaded image for project: 'Confluence Server'
  1. Confluence Server
  2. CONFSERVER-29000

If mail.smtp.auth is ever set to true in a mail server config, it is never set to false again when usernames and passwords are removed.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: 5.0, 5.1, 5.1.2, 5.1.3
    • Fix Version/s: 5.6
    • Component/s: None

      Description

      The problem

      In /com/atlassian/mail/server/AbstractMailServer.class the mail protocol is set to require authentication if a username and password is given:

      if (StringUtils.isNotBlank(getUsername()))
      {
        props.put("mail."+protocol+".auth", "true");
        isAuthenticating = true;
      }
      

      This is never set to false if the username and password are removed.

      The solution

      Ideally, change the code to this:

      if (StringUtils.isNotBlank(getUsername()))
      {
        props.put("mail."+protocol+".auth", "true");
        isAuthenticating = true;
      }
      else
      {
        props.put("mail."+protocol+".auth", "false");
      }
      

      Workaround

      1. Remove the mail server configuration from Admin > Mail Servers
      2. Create a new configuration, ensuring that no username or password (including whitespace) is saved at all.

      Steps to Reproduce

      1. Have an SMTP mail server that accepts anonymous connections
      2. Create a mail server in Confluence with a username and password, and save it
      3. Remove the username and password and save
      4. Expected behaviour: The authentication works anonymously
      5. Actual behavior: The connection doesn't work and this stack trace occurs:
        2013-04-02 14:27:00,119 ERROR [scheduler_Worker-2] [atlassian.core.task.AbstractErrorQueuedTaskQueue] handleException com.atlassian.mail.MailException: javax.mail.AuthenticationFailedException: failed to connect, no user name specified?
        com.atlassian.mail.MailException: javax.mail.AuthenticationFailedException: failed to connect, no user name specified?
        	at com.atlassian.mail.server.impl.SMTPMailServerImpl.send(SMTPMailServerImpl.java:193)
        	at com.atlassian.confluence.jmx.JmxSMTPMailServer.send(JmxSMTPMailServer.java:80)
        	at com.atlassian.confluence.mail.template.AbstractMailNotificationQueueItem.send(AbstractMailNotificationQueueItem.java:135)
        	at com.atlassian.confluence.mail.template.PreRenderedMailNotificationQueueItem.send(PreRenderedMailNotificationQueueItem.java:140)
        	at com.atlassian.confluence.mail.template.AbstractMailNotificationQueueItem.execute(AbstractMailNotificationQueueItem.java:106)
        	at com.atlassian.core.task.AbstractErrorQueuedTaskQueue$TaskDecorator.execute(AbstractErrorQueuedTaskQueue.java:107)
        	at com.atlassian.core.task.AbstractTaskQueue.flush(AbstractTaskQueue.java:45)
        	at com.atlassian.core.task.AbstractErrorQueuedTaskQueue.flush(AbstractErrorQueuedTaskQueue.java:37)
        	at com.atlassian.quartz.jobs.TaskQueueFlushJob.doExecute(TaskQueueFlushJob.java:32)
        	at com.atlassian.quartz.jobs.AbstractJob.executeInternal(AbstractJob.java:88)
        	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
        	at com.atlassian.confluence.setup.quartz.DelegatingClusterAwareQuartzJobBean.executeJob(DelegatingClusterAwareQuartzJobBean.java:16)
        	at com.atlassian.confluence.setup.quartz.AbstractClusterAwareQuartzJobBean.surroundJobExecutionWithLogging(AbstractClusterAwareQuartzJobBean.java:64)
        	at com.atlassian.confluence.setup.quartz.AbstractClusterAwareQuartzJobBean.executeInternal(AbstractClusterAwareQuartzJobBean.java:46)
        	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
        	at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
        	at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:20)
        	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
        Caused by: javax.mail.AuthenticationFailedException: failed to connect, no user name specified?
        	at javax.mail.Service.connect(Service.java:326)
        	at javax.mail.Service.connect(Service.java:176)
        	at javax.mail.Service.connect(Service.java:125)
        	at com.atlassian.mail.server.impl.SMTPMailServerImpl.send(SMTPMailServerImpl.java:164)
        	... 17 more
        

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                14 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Last commented:
                  5 years, 4 weeks, 1 day ago