【问题标题】:Sent Email in Google Cloud Service在 Google Cloud Service 中发送电子邮件
【发布时间】:2017-04-28 11:26:19
【问题描述】:

我对使用现有应用程序在 Google Cloud 服务中配置电子邮件有一些疑问

1.我们使用 587 端口的 gmail 帐户配置了 SMTP,并尝试从我们的谷歌云实例发送邮件,没有发送电子邮件。我们尝试 ping 到端口 587,它显示连接被拒绝。为什么会这样?

2.我们在 Google 云平台中看到了使用 SMTP-Relay 发送电子邮件的选项。我们如何使用 SMTP-Relay 设置通过 Google Apps 电子邮件/gmail 配置和设置 SMTP?

  1. 是否有任何选项可以在不使用第三方合作伙伴(如 SendGrid、Mailgun 和 Mailjet)的情况下从谷歌云为我们现有的应用程序(如 mantis)发送电子邮件?

【问题讨论】:

  • 您的意思是您尝试远程登录到 smtp.gmail.com 的 587 端口?如果您无法远程登录,则应联系 Google Cloud 支持

标签: email google-app-engine google-cloud-platform mantis


【解决方案1】:

我能够使用以下 mailx 命令从我们的 Google Compute 实例发送电子邮件:

# the body of the alert email is saved to a temprary file
echo "Hello. This is a test message" > /tmp/mail_body.txt
# the mailx command is used to send the email. it sends the email using gmail server.
# this is useful on servers that have limited access to email servers such as Google Compute instance
mailx -s "Email Subject" -r "reply_email" -S smtp="smtp.gmail.com:587" -S    \
smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="gmail_address" -S smtp-auth-password="gmail_password" -S \
ssl-verify=ignore recepiant_email < /tmp/mail_body.txt
# the temprary file is removed
rm -rf /tmp/mail_body

【讨论】:

    【解决方案2】:

    您不能使用端口 587,因为 GCP 会阻止来自该端口的所有出站流量,我建议您使用端口 2525,因为这是 GCP 不会阻止的唯一 smtp 端口。

    【讨论】:

      【解决方案3】:

      Google Cloud Engine 在 587 上阻止出站流量,请尝试使用端口 2587。

      【讨论】:

        猜你喜欢
        • 2021-06-06
        • 1970-01-01
        • 2017-05-11
        • 2015-04-25
        • 2015-10-14
        • 2014-09-14
        • 1970-01-01
        • 1970-01-01
        • 2019-03-02
        相关资源
        最近更新 更多