从 cron 发送电子邮件到 Gmail

从 cron 发送电子邮件到 Gmail

寻求帮助,从我的 cron 向 gmail 地址发送电子邮件。在 crontab 的顶部

MAILTO="[email protected]"

但没有邮件。检查 /var/log/maillog,我发现

Dec 17 22:46:36 myserver postfix/pickup[30426]: CC21261C6E: uid=501 from=<root>
Dec 17 22:46:36 myserver postfix/cleanup[30486]: CC21261C6E: message-id=<[email protected]>
Dec 17 22:46:36 myserver postfix/qmgr[11071]: CC21261C6E: from=<[email protected]>, size=5920, nrcpt=1 (queue active)
Dec 17 22:46:37 myserver postfix/smtp[30488]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400e:c03::1b]:25: Network is unreachable
Dec 17 22:46:37 myserver postfix/smtp[30488]: CC21261C6E: enabling PIX workarounds: disable_esmtp delay_dotcrlf for gmail-smtp-in.l.google.com[74.125.197.26]:25
Dec 17 22:46:37 myserver postfix/smtp[30488]: CC21261C6E: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.197.26]:25, delay=221, delays=220/0.02/0.34/0.39, dsn=2.0.0, status=sent (250 2.0.0 OK 1545086797 31si11773098plk.310 - gsmtp)
Dec 17 22:46:37 myserver postfix/qmgr[11071]: CC21261C6E: removed

因此,很明显,IPv6 版本被阻止了,但回退会收到成功消息,但邮件从未到达。如果我尝试使用命令行邮件命令,也会收到相同的消息。但是,我可以使用命令行邮件程序成功将邮件发送到我的公司电子邮件地址。

mail -s "test1" [email protected]
test1
EOT

telnet 技巧似乎表明我可以访问 gmail 服务器:

$ telnet gmail-smtp-in.l.google.com 25
Trying 108.177.98.26...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 *************************************************
^]

telnet> quit
Connection closed.

我的 IP 表如下所示

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

任何帮助都将不胜感激。

答案1

谢谢@ivanivan。Gmail 将我所有的 cron 输出整理到垃圾邮件文件夹中,默认情况下该文件夹不会显示在 Gmail 界面中。(这似乎是正确的做法,因为发件人“[电子邮件保护]相当粗略。)一旦我显示垃圾邮件文件夹并查看内部,我就会看到所有 cron 输出。(看看我通过 telnet 进入邮件服务器并查看 iptables。)哎呀!... 再次非常感谢你。

相关内容