Redhat + Postfix:发送电子邮件只能从命令行运行

所以我有一个ruby的应用程序,当有错误发送电子邮件,但它似乎并没有工作。 以下是发生这种情况的日志:

在/ var /日志/ mailerlog:

Sep 30 14:09:58 511914-db2 postfix/qmgr[1975]: 7794E5A02BD: removed Sep 30 14:09:59 511914-db2 postfix/smtpd[9407]: connect from localhost[127.0.0.1] Sep 30 14:09:59 511914-db2 postfix/smtpd[9407]: 2471A5A02BD: client=localhost[127.0.0.1] Sep 30 14:09:59 511914-db2 postfix/cleanup[9410]: 2471A5A02BD: message-id=<[email protected]> Sep 30 14:09:59 511914-db2 postfix/smtpd[9407]: disconnect from localhost[127.0.0.1] Sep 30 14:09:59 511914-db2 postfix/qmgr[1975]: 2471A5A02BD: from=<[email protected]>, size=5354, nrcpt=1 (queue active) Sep 30 14:09:59 511914-db2 postfix/smtp[9411]: connect to aspmx.l.google.com[2607:f8b0:4003:c02::1b]:25: Network is unreachable Sep 30 14:09:59 511914-db2 postfix/smtp[9411]: 2471A5A02BD: to=<[email protected]>, relay=aspmx.l.google.com[173.194.64.27]:25, delay=0.31, delays=0.06/0/0.05/0.2, dsn=2.0.0, status=sent (250 2.0.0 OK 1380568199 xq2si1045224obc.109 - gsmtp) 

但是,当我尝试从命令行发送电子邮件时,它可以工作:

echo "Test email sent from db2" | /usr/sbin/sendmail [email protected]

这在我的/ var / log / maillog中产生:

  echo "Test email sent from db2" | /usr/sbin/sendmail [email protected] [mysite@511914-db2 ~]$ sudo su [sudo] password for mysite: [root@511914-db2 mysite]# cd /var/log [root@511914-db2 log]# tail -f maillog Sep 30 15:46:27 511914-db2 postfix/pickup[12986]: E78C05A0686: uid=502 from=<mysite> Sep 30 15:46:27 511914-db2 postfix/cleanup[16776]: E78C05A0686: message-id=<[email protected]> Sep 30 15:46:27 511914-db2 postfix/qmgr[1975]: E78C05A0686: from=<[email protected]>, size=349, nrcpt=1 (queue active) Sep 30 15:46:27 511914-db2 postfix/smtp[16778]: connect to aspmx.l.google.com[2607:f8b0:4003:c02::1a]:25: Network is unreachable Sep 30 15:46:28 511914-db2 postfix/smtp[16778]: E78C05A0686: to=<[email protected]>, relay=aspmx.l.google.com[173.194.64.27]:25, delay=0.4, delays=0.07/0.01/0.1/0.23, dsn=2.0.0, status=sent (250 2.0.0 OK 1380573988 pu10si1222849obb.113 - gsmtp) Sep 30 15:46:28 511914-db2 postfix/qmgr[1975]: E78C05A0686: removed 

从外观看,电子邮件正在发送。 但是,除了当我通过命令行运行该命令时,我没有收到任何东西。 它可以disconnect from localhost[127.0.0.1]这是搞砸了?

让我知道如果你需要更多的信息,我会粘贴它。

你的第一个结果的最后一行表示(除别的之外)“status = sent”,就像第二个输出中的倒数第二行一样。 这意味着邮件发送成功,Gmail邮件服务器接受发送。 Postfix尝试最初通过IPv6连接,当它失败时,它通过IPv4连接。 你不需要做任何事情 – 一切工作正常。