-
Bug
-
Resolution: Fixed
-
Low
-
5.0, 5.1, 5.1.2, 5.1.3
-
None
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
- Remove the mail server configuration from Admin > Mail Servers
- Create a new configuration, ensuring that no username or password (including whitespace) is saved at all.
Steps to Reproduce
- Have an SMTP mail server that accepts anonymous connections
- Create a mail server in Confluence with a username and password, and save it
- Remove the username and password and save
- Expected behaviour: The authentication works anonymously
- 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