【发布时间】:2016-12-31 09:06:44
【问题描述】:
我在我的 Google Cloud Compute Engine 上安装了一个 WordPress 网站,但我无法发送邮件。于是在网上搜索后发现Sendmail。
安装并配置了最新版本:
$ sudo apt-get update
$ sudo apt-get install sendmail
运行 sendemail 配置,对所有内容都回答“是”:
$ sudo sendmailconfig
编辑了127.0.0.1 localhost instance-1 行(instance-1 是我的 Google 云实例):
$ sudo vim /etc/hosts # changed
重启 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
>>> .
我的日志文件/var/log/mail.log 显示了很多这样的行:
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.
【问题讨论】:
-
你检查过 sendmail 的日志文件吗?
-
@AndrzejA.Filip 在我的问题中检查我的 mail.log 文件的输出。
-
查看您的日志文件我会说您运行 sendmail 的主机无法连接到 Internet。您可以通过从终端运行以下命令来检查这一点:nc alt4.gmail-smtp-in.l.google.com 25
-
@PeterSkarpetis 我按照你说的那样运行了命令,但是我什么也没得到,我也不能再输入命令了。这是什么意思?
-
您无法从 Google Compute Engine 发送邮件,Google 会在 25 日阻止所有传出流量。您必须使用像 Sendgrid 这样的第三方来发送邮件。 cloud.google.com/compute/docs/tutorials/sending-mail
标签: apache google-cloud-platform debian google-compute-engine sendmail