Jose
Jose

Reputation: 1829

Mail properties in Production - Jhipster 4.2.8

I have the following configuration of the mail account of my company in develop, which goes perfectly:

mail:
    host: smtp.xxx.es
    port: 587
    username: [email protected]
    password: xxxx
    protocol: smtp
    #tls: true
    properties.mail.smtp:
        auth: true
        from: [email protected]
        starttls.enable: true
        ssl.trust: smtp.xxx.es

I copy de same data from "application-dev.yml" to "application-prod.yml".

I make the deployment in Google Cloud.

It does not send me mails and the logs tells me the following:

: Email could not be sent to user '[email protected]': Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.xxx.es, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out). Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.xxx.es, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out)

Can somebody help me?

Upvotes: 1

Views: 826

Answers (1)

Julien Dubois
Julien Dubois

Reputation: 3688

As described in the Google Cloud documentation you can't send e-mail from your Google Cloud VM using port 587. So this has nothing to do with JHipster, it's a limitation from your cloud provider.

I personally use Mailgun, which uses port 2525 (which is allowed by Google Cloud), here is my configuration for https://start.jhipster.tech (a JHipster application that runs on Google Cloud):

spring:
    mail:
        host: smtp.mailgun.org
        port: 2525
        username: [email protected]
        password: xxxxx

As Mailgun provides a generious free tier you can test this for free - in fact I use it in production and haven't paid anything yet!

Upvotes: 1

Related Questions