Error while configuring mail server

Hi,

We are not able to configure mail server and we are getting error as

"Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587" and also we have tried to configure our smtp server and getting error as "Caused by: java.net.SocketException: Permission denied: connect"

Kindly help us to resolve this error. NOTE: We are trying this from both Windows and Linux OS.

Here are the logs for both scenarios,

***** When tried to configure our gmail smtp server as instructed *****

[catalina.jar:7.0.32]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [catalina.jar:7.0.32]

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.32]

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [catalina.jar:7.0.32]

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) [tomcat-coyote.jar:7.0.32]

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) [tomcat-coyote.jar:7.0.32]

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) [tomcat-coyote.jar:7.0.32]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_10]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_10]

at java.lang.Thread.run(Thread.java:722) [na:1.7.0_10]

Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642) ~[mail-1.4.5.jar:1.4.5]

at javax.mail.Service.connect(Service.java:295) ~[mail-1.4.5.jar:1.4.5]

at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]

... 206 common frames omitted

Caused by: java.net.ConnectException: Connection timed out: connect

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.7.0_10]

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_10]

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) ~[na:1.7.0_10]

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) ~[na:1.7.0_10]

at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_10]

at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:317) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938) ~[mail-1.4.5.jar:1.4.5]

... 209 common frames omitted

#####################################################################################################################

***** When tried to configure our smtp servers *****

[catalina.jar:7.0.32]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [catalina.jar:7.0.32]

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.32]

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.32]

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [catalina.jar:7.0.32]

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) [tomcat-coyote.jar:7.0.32]

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) [tomcat-coyote.jar:7.0.32]

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) [tomcat-coyote.jar:7.0.32]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_10]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_10]

at java.lang.Thread.run(Thread.java:722) [na:1.7.0_10]

Caused by: javax.mail.MessagingException: Could not connect to SMTP host: remotesmtp.hostName.com, port: 25

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642) ~[mail-1.4.5.jar:1.4.5]

at javax.mail.Service.connect(Service.java:295) ~[mail-1.4.5.jar:1.4.5]

at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389) ~[spring-context-support-3.1.2.RELEASE.jar:3.1.2.RELEASE]

... 177 common frames omitted

Caused by: java.net.SocketException: Permission denied: connect

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.7.0_10]

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_10]

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_10]

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) ~[na:1.7.0_10]

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) ~[na:1.7.0_10]

at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_10]

at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:317) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233) ~[mail-1.4.5.jar:1.4.5]

at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938) ~[mail-1.4.5.jar:1.4.5]

... 180 common frames omitted

2013-02-19 19:52:48,054 INFO [AtlassianEvent::pool-3-thread-3] hcmd48 1192x895x1 1cr4ov8 10.232.70.66 "POST /admin/mail-server HTTP/1.1" stash.mail-log MailService reconfigured

2013-02-19 19:53:14,587 ERROR [http-bio-7990-exec-3] hcmd48 1192x900x1 1cr4ov8 10.232.70.66 "POST /admin/mail-server HTTP/1.1" stash.mail-log Message not sent: Mail sending failed; recipient: a22732@companyName.com; subject: MOTOROLA - Test email for your SMTP configuration

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 857;

nested exception is:

java.net.ConnectException: Connection timed out: connect. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 857;

nested exception is:

java.net.ConnectException: Connection timed out: connect

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:205) [stash-service-impl-2.0.2.jar:na]

at com.atlassian.stash.internal.mail.MailServiceImpl.sendTest(MailServiceImpl.java:198) [stash-service-impl-2.0.2.jar:na]

at sun.reflect.GeneratedMethodAccessor450.invoke(Unknown Source) ~[na:na]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_10]

at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_10]

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:61) [spring-security-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at $Proxy190.sendTest(Unknown Source) [na:na]

at com.atlassian.stash.internal.web.admin.MailServerConfigurationController.testSettings(MailServerConfigurationController.java:77) [MailServerConfigurationController.class:na]

at sun.reflect.GeneratedMethodAccessor449.invoke(Unknown Source) ~[na:na]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_10]

at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_10]

at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) [spring-webmvc-3.1.2.RELEASE.jar:3.1.2.RELEASE]

1 answer

1 accepted

This widget could not be displayed.

Hi Amit,

Looks like there might be two different problems here. The first error "Permission denied: connect" is sometimes caused by a bug on JDK7, which can be fixed by adding the following to setenv.sh or setenv.bat on Windows.

-Djava.net.preferIPv4Stack=true

Another exception is talking about port 857, which is incorrect. It should be port 465 (with SSL) or port 587 (with TLS),

http://support.google.com/mail/bin/answer.py?hl=en&answer=78775

I hope this helps.

Charles

Ivan Tse Atlassian Team Feb 19, 2013

You should also check the protocol you're using. I believe that google apps only allow secure prococols (SMTP/S, IMAP/S, POP/s). Make sure those protocols are selected.

In JIRA there is an option to just ust the pre-definied Google Apps/Gmail option that should populate the right options.

Hi Charles and Ivan,

Thanks for reply, it worked for me. :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,327 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you