I Can not access smtp.gmail.com 587 from OVH Managed Kubernetes Cluster

3/24/2020

I am using Spring Mail service in a Spring-boot App to send mail to my users.

This configuration works perfectly on my localhost:

## Mail configuration
mail:
 host: smtp.gmail.com
 port: 587
 username: myemail@gmail.com  
 password: app_password 
 protocol: smtp
 tls: true
 properties.mail.smtp:
  auth: true
  starttls.enable: true
  ssl.trust: smtp.gmail.com

But when I deploy the app on an OVH Managed Kubernetes cluster, it doesn't succeed getting to the mail server. It fails with a connection timeout error.

When I try telnet smtp.gmail.com 587 on my localhost it works,

But these are the results of the connection tests made from a container in the cluster:

ping smtp.gmail.com ===> Works

telnet smtp.gmail.com 587 
   Trying xx.xxx.xxx.109...
   Connection failed: Connection timed out
   Trying xxxx:xxxx:xxxx:xxx::6c...
   telnet: Unable to connect to remote host: Cannot assign requested address

This leads me to think it is an implicit firewall rule blocking outbound traffic from the cluster.

But somebody told me he is using the same params for the same cluster provider in the same region and it's working.

The only difference with him is that instead of using the Gmail address password and allow less secured app Google settings, I am using an App password as recommended by google.

Do you think Gmail is blocking the incoming request from the server without even notifying me?

Is it related to the fact I'm using an app password? (works like a charm on localhost)

Is it an ovh related problem?

Thanks for your help.

-- Philippe Simo
email
kubernetes
ovh
spring-boot

1 Answer

4/27/2020

OVH, on its Public Cloud offering, may block the outgoing SMTP / SUBMISSION port by default. That was the case for 2 of my project.

You may need to contact them to get them to allow your Public Cloud Project to access SMTP port.

-- Maiko Bossuyt
Source: StackOverflow