邮件从sendmail失败 – CentOS 7

我简单的PHP脚本发送邮件是

<?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $from = "[email protected]"; $to = "[email protected]"; $subject = "PHP Mail Test script"; $message = "This is a test to check the PHP Mail functionality"; $headers = "From:" . $from; mail($to,$subject,$message, $headers); echo "Test email sent"; ?> 

当我在任何其他服务器上运行这个脚本时,它工作正常,但是当我在新的CentOS 7机器上执行时,我总是在/ var / log / maillog中出错

 Mar 15 19:08:38 host sendmail[1521]: u2FN8cfK001521: from=root, size=23, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost Mar 15 19:08:38 host sendmail[1522]: u2FN8cTc001522: from=<[email protected]>, size=328, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1] Mar 15 19:08:38 host sendmail[1521]: u2FN8cfK001521: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30023, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (u2FN8cTc001522 Message accepted for delivery) Mar 15 19:08:38 host sendmail[1524]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128 Mar 15 19:08:39 host sendmail[1524]: u2FN8cTc001522: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120328, relay=gmail-smtp-in.l.google.com. [IPv6:2607:f8b0:400d:c06::1a], dsn=5.0.0, stat=Service unavailable Mar 15 19:08:39 host sendmail[1524]: u2FN8cTc001522: u2FN8dTc001524: DSN: Service unavailable Mar 15 19:08:39 host sendmail[1524]: u2FN8dTc001524: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31588, dsn=2.0.0, stat=Sent 

与其他公共邮件服务器(Yahoo!,Hotmail)不同,Gmail必须在SPFlogging下validation相应的IP地址。 而且由于sendmail一直在通过IPv6发送电子邮件,所以在SPFlogging中并不存在。 所以我只是简单地将IPv6添加到SPFlogging中,一切正常。

所以,现在我的SPFlogging看起来像这样

v = spf1 mx a ip6:2547:2200:60:9a2a :: / 64 ip4:44.33.33.104/32 a:mail.example.org include:example.org〜all