Mail server connection failed with GMail

Miscellaneous

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

After configuring the mail server in Stash to use GMail with port 465, sending a test email fails with the following log:

2012-10-16 11:31:10,467 ERROR [http-7990-4] wileecoyote 690x205x1 9jwjip 0:0:0:0:0:0:0:1%0 "POST /admin/mail-server HTTP/1.1" stash.mail-log Message not sent: Mail sending failed; recipient: wileecoyote@acme.com; subject: Stash 1.3.0 - Test email for your SMTP configuration
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
  nested exception is:
	java.net.SocketTimeoutException: Read timed out. Failed messages: javax.mail.MessagingException: Exception reading response;
  nested exception is:
	java.net.SocketTimeoutException: Read timed out
	at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:400) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]
	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]
	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:355) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]
	at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]
	at com.atlassian.stash.internal.mail.MailServiceImpl.sendMessageSynchronously(MailServiceImpl.java:198) [stash-service-impl-1.3.0.jar:na]
	at com.atlassian.stash.internal.mail.MailServiceImpl.sendTest(MailServiceImpl.java:191) [stash-service-impl-1.3.0.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_35]
(...)
Caused by: javax.mail.MessagingException: Exception reading response
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2153) ~[mail-1.4.4.jar:1.4.4]
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1912) ~[mail-1.4.4.jar:1.4.4]
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) ~[mail-1.4.4.jar:1.4.4]
	at javax.mail.Service.connect(Service.java:295) ~[mail-1.4.4.jar:1.4.4]
	at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]
	... 158 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.6.0_35]
	at java.net.SocketInputStream.read(SocketInputStream.java:129) ~[na:1.6.0_35]
	at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110) ~[mail-1.4.4.jar:1.4.4]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) ~[na:1.6.0_35]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:237) ~[na:1.6.0_35]
	at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89) ~[mail-1.4.4.jar:1.4.4]
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2131) ~[mail-1.4.4.jar:1.4.4]
	... 162 common frames omitted

Cause

Port 465 shows up in Appendix A of the 1996 non-standard The SSL Protocol Version 3.0 as "Simple Mail Transfer Protocol with SSL". Unfortunately, it's not registered for SMTPs. It's registered for URD - "URL Rendezvous Directory for SSL" by Cisco. The recommended approach, at least for authentication, is to use STARTTLS encryption on port 587.

Port 25 can be used but it is for server to relay messages to one another. Port 587 is recommended because this way ISPs can block outgoing SMTP on their networks but still allow users to send email to another mail server.

Resolution

See  Configure the Mail Server to Use GMail
Last modified on Nov 2, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.