生产中的邮件属性 - Jhipster 4.2.8

时间:2017-11-22 13:45:46

标签: spring-boot javamail jhipster

我在开发中拥有以下我公司邮件帐户的配置,完美无缺:

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 Cloud中进行部署。

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

: 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)

有人能帮助我吗?

1 个答案:

答案 0 :(得分:1)

Google Cloud documentation所述,您无法使用端口587从Google Cloud 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提供了一个免费的免费套餐,你可以免费测试 - 事实上我在生产中使用它并且还没有付款!