Email notification through Gmail: Connection Timeout to smtp.gmail.com:587
I get the following error [ERROR] Sending the email to the following server failed : smtp.gmail.com:587: Could not connect to SMTP host: smtp.gmail.com, port: 587: Connection timed out -> [Help 1]
The plugin I'm trying to use to send the mail is the following:
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>maven-postman-plugin</artifactId>
<executions>
<execution>
<id>send a mail</id>
<phase>package</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>false</inherited>
<configuration>
<from>library.ci.build@gmail.com</from>
<subject>Build ${env.BUILD_NUMBER}</subject>
<failonerror>true</failonerror>
<mailssl>true</mailssl>
<mailcontenttype>text/html</mailcontenttype>
<mailhost>smtp.gmail.com</mailhost>
<!-- to get out of Jazz: 587 -->
<mailport>587</mailport>
<mailuser>XXX</mailuser>
<mailpassword>XXX</mailpassword>
<mailAltConfig>true</mailAltConfig>
<htmlMessage>Build page here: <a href="https://hub.jazz.net/pipeline/corneliupetrescu/LibraryBackend/builds/4acc9fca-7562-4546-af3b-3e6b36c1ab48/${TASK_ID}">https://hub.jazz.net/pipeline/corneliupetrescu/LibraryBackend/builds/4acc9fca-7562-4546-af3b-3e6b36c1ab48/${TASK_ID}</a></htmlMessage>
<receivers>
<!-- <receiver>${git.commit.user.email}</receiver> -->
<receiver>victorrentea@gmail.com</receiver>
</receivers>
</configuration>
</execution>
</executions>
</plugin>
From my local machine, this works OK.
Do you have any idea? Please help.
4 answers
Hi Simon,
Thank you for your answer !
You're right. I've mixed the two. I tried again:
Thank you!
Victor
Thank you for your answer !
You're right. I've mixed the two. I tried again:
<mailssl>true</mailssl> <mailport>465</mailport>and
<mailssl>false</mailssl> <mailport>587</mailport>Both configurations hang for ~1 min when sending the mail, and then result in error:
[ERROR] Sending the email to the following server failed : smtp.gmail.com:587: Could not connect to SMTP host: smtp.gmail.com, port: 587: Connection timed out
I suspect that there is some port blocking in place, but I don't know how to work around it. I say this because I've tried to set the server to www.gmail.com : 80 and there was some response (that caused an error afterall) -- but at least there was some response from the remote server.
Thank you!
Victor
Hi Victor, to check if there is a firewall blocking your access to these ports, try the following command from a DOS window (on Windows) or a terminal window (Linux or Unix).
telnet smtp.gmail.com 587
You should see the response:
220 mx.google.com ESMTP c8sm40836399wjw.6 - gsmtp
On Windows type "Ctrl+$" then "quit" to exit "telnet"
On Linux and Unix type "Ctrl+]" then "quit" to exit "telnet"
If you do not see the reply from google then something on your network is blocking the port. Ask your system administrator.
Cheers, Simon
telnet smtp.gmail.com 587
You should see the response:
220 mx.google.com ESMTP c8sm40836399wjw.6 - gsmtp
On Windows type "Ctrl+$" then "quit" to exit "telnet"
On Linux and Unix type "Ctrl+]" then "quit" to exit "telnet"
If you do not see the reply from google then something on your network is blocking the port. Ask your system administrator.
Cheers, Simon
Sorry, you will have to talk to your server administrator, you will need access to the server that is contacting Google in order to debug this problem. If you can not have direct access, maybe your server administrator can run the commands; The server administrator will also know if there is a firewall setup on the server or between the server and the internet that could block these outgoing requests.
Cheers,
Simon
Cheers,
Simon