在Google Cloud Service中发送电子邮件

问题描述 投票:2回答:3

关于在现有应用程序中配置Google Cloud服务中的电子邮件,我有些疑问

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

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

  1. 是否有任何选项可以在不使用SendGrid,Mailgun和Mailjet等第三方合作伙伴的情况下,为我们现有的应用程序(如mantis)发送来自Google云端的电子邮件?
email google-app-engine google-cloud-platform mantis
3个回答
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

0
投票

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


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.