<p>I am using <code>Spring Mail service</code> in a <code>Spring-boot</code> App to send mail to my users.    </p>

<p>This configuration <strong>works perfectly</strong> on my localhost:    </p>

<pre><code>## 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
</code></pre>

<p>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 <code>connection timeout error</code>.   </p>

<p>When I try <code>telnet smtp.gmail.com 587</code> on my localhost it works,   </p>

<p>But these are the results of the connection tests made from a container in the cluster:   </p>

<p><code>ping smtp.gmail.com ===&gt; Works</code>  </p>

<pre><code>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
</code></pre>

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

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

<p>The only difference with him is that instead of using the Gmail address password and <a href="https://support.google.com/accounts/answer/6010255?hl=en" rel="nofollow noreferrer">allow less secured app</a> Google settings, I am using an <a href="https://support.google.com/accounts/answer/185833" rel="nofollow noreferrer">App password as recommended by google</a>.</p>

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

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

<p>Is it an ovh related problem?</p>

<p>Thanks for your help.</p>

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

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