Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Sendmail不从GCE VM实例发送电子邮件_Apache_Google Cloud Platform_Debian_Google Compute Engine_Sendmail - Fatal编程技术网

Apache Sendmail不从GCE VM实例发送电子邮件

Apache Sendmail不从GCE VM实例发送电子邮件,apache,google-cloud-platform,debian,google-compute-engine,sendmail,Apache,Google Cloud Platform,Debian,Google Compute Engine,Sendmail,我已经在我的谷歌云计算引擎上安装了WordPress网站,但我无法发送邮件。于是在网上搜索后发现 通过以下方式安装并配置了最新版本: $ sudo apt-get update $ sudo apt-get install sendmail 运行sendemail配置,对所有内容回答“是”: $ sudo sendmailconfig 编辑了127.0.0.1 localhost instance-1行(instance-1是我的谷歌云实例): 重新启动Apache: sudo servic

我已经在我的谷歌云计算引擎上安装了WordPress网站,但我无法发送邮件。于是在网上搜索后发现

通过以下方式安装并配置了最新版本:

$ sudo apt-get update
$ sudo apt-get install sendmail
运行sendemail配置,对所有内容回答“是”:

$ sudo sendmailconfig
编辑了
127.0.0.1 localhost instance-1
行(instance-1是我的谷歌云实例):

重新启动Apache:

sudo service apache2 restart
当我在终端中运行下面的命令时,什么也不会发生,我也不能再运行命令了。因此,这一过程似乎没有结束

$ sendmail example@email.com
$date | sendmail-v的输出example@email.com
返回:

example@email.com... Connecting to [127.0.0.1] via relay...
220 instance-1.c.myproject.internal ESMTP Sendmail 8.14.4/8.14.4/Debian-8; Wed, 24 Aug 2016 09:42:18 GMT; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO instance-1.c.myproject.internal
250-instance-1.c.myproject.internal Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<info@instance-1.c.myproject.internal> SIZE=29
250 2.1.0 <info@instance-1.c.myproject.internal>... Sender ok
>>> RCPT To:<example@email.com>
>>> DATA
250 2.1.5 <example@email.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .

您无法从谷歌计算引擎发送邮件,谷歌将在25日阻止所有传出流量


您将必须使用第三方,如。

是的,可以从实例发送电子邮件,所有内容都在本文中解释


默认情况下,Compute Engine允许在除端口25之外的所有端口上进行出站连接,端口25因滥用风险而被阻止。所有其他端口都已打开,包括端口587和465。

无法直接从GCE虚拟机发送电子邮件。

请查看以下文档:

  • 到TCP目标端口25(SMTP)的出口流量
此外,在:

由于存在滥用的风险,当目标位于VPC网络外部时,到目标TCP端口25的连接总是被阻止。这包括在Google Workspace中使用SMTP中继

根据维基百科的文章:

自1981年引入SMTP以来,它一直在更新、修改和更新 扩展多次。目前常用的协议版本有 具有各种身份验证扩展的可扩展结构, 加密、二进制数据传输、国际化电子邮件地址。 SMTP服务器通常在端口上使用传输控制协议 25号

这是1982年第一次决定,此后一直如此。在下一页,您可以看到:

4.5.4.2。接收策略

SMTP服务器应尝试在SMTP服务器上保留挂起的侦听 端口(IANA指定为端口25)在任何时候

这是什么意思?您不能简单地更改端口,因为没有机制让其他SMTP服务器知道您正在使用非标准端口,并且您不能使用任何其他端口发送到其他服务器

有没有办法从GCE虚拟机发送电子邮件?

是的,让我们回到文档:

谷歌云对使用目标TCP端口587或465发送到外部目标IP地址的流量没有任何限制


端口587和465可用于SMTP邮件提交()。这意味着您可以使用外部邮件中继(您自己的或第三方)进行经过身份验证的SMTP,并且此服务器处理到端口25上其他邮件系统的传递。例如,您可以使用以下第三方服务:,或。此外,您还可以通过或仅使用转发邮件。

您检查过sendmail的日志文件吗?@AndrzejA.Filip检查我问题中my mail.log文件的输出。查看您的日志文件,我会说您运行sendmail的主机无法连接到internet。您可以通过从终端运行以下命令来检查这一点:nc alt4.gmail-smtp-in.l.google.com25@PeterSkarpetis我像你说的那样运行了命令,但是我没有得到任何回报,我不能再键入命令了。这意味着什么?你不能从谷歌计算引擎发送邮件,谷歌会在25小时内阻止所有发送流量。您必须使用Sendgrid这样的第三方来发送邮件。
example@email.com... Connecting to [127.0.0.1] via relay...
220 instance-1.c.myproject.internal ESMTP Sendmail 8.14.4/8.14.4/Debian-8; Wed, 24 Aug 2016 09:42:18 GMT; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO instance-1.c.myproject.internal
250-instance-1.c.myproject.internal Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<info@instance-1.c.myproject.internal> SIZE=29
250 2.1.0 <info@instance-1.c.myproject.internal>... Sender ok
>>> RCPT To:<example@email.com>
>>> DATA
250 2.1.5 <example@email.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
Aug 25 07:56:02 instance-1 sm-mta[19958]: u7OCN1Wu013988: to=<example@email.com>, delay=19:33:01, xdelay=00:10:36, mailer=esmtp, pri=5340422, relay=alt4.gmail-smtp-in.l.google.com. [173.194.72.27], dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Aug 25 07:56:02 instance-1 sm-mta[19958]: u7OC9iDu013870: to=<example@email.com>, delay=19:46:18, xdelay=00:00:00, mailer=esmtp, pri=10560423, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Aug 25 07:56:02 instance-1 sm-mta[19958]: u7OBliSC013710: to=<example@email.com>, delay=20:08:18, xdelay=00:00:00, mailer=esmtp, pri=10740386, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Aug 25 07:56:02 instance-1 sm-mta[19958]: u7O94ubM013110: to=<example@email.com>, delay=22:51:06, xdelay=00:00:00, mailer=esmtp, pri=11460376, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.