生产环境中的邮件属性 - Jhipster 4.2.8

Mail properties in Production - Jhipster 4.2.8

我在develop中对我公司的邮箱进行了如下配置,完美运行:

mail:
    host: smtp.xxx.es
    port: 587
    username: notifications-noreply@xxx.es
    password: xxxx
    protocol: smtp
    #tls: true
    properties.mail.smtp:
        auth: true
        from: notifications-noreply@xxx.es
        starttls.enable: true
        ssl.trust: smtp.xxx.es

我将相同的数据从 "application-dev.yml" 复制到 "application-prod.yml"。

我在 Google 云中进行部署。

它不给我发邮件,日志告诉我以下内容:

: Email could not be sent to user 'joseluis.xxx@xxx.com': 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)

有人可以帮助我吗?

Google Cloud documentation 中所述,您无法使用端口 587 从 Google 云 VM 发送电子邮件。所以这与 JHipster 无关,这是您的云的限制提供商。

我个人使用 Mailgun,它使用端口 2525(Google Cloud 允许),这是我对 https://start.jhipster.tech(运行在 Google Cloud 上的 JHipster 应用程序)的配置):

spring:
    mail:
        host: smtp.mailgun.org
        port: 2525
        username: xxxxx@mg.jhipster.tech
        password: xxxxx

由于 Mailgun 提供了一个慷慨的免费层,您可以免费测试它 - 事实上我在生产中使用它并且还没有支付任何费用!