Sendmail / postfix邮件不是从本地Mac OS X(Mountain Lion)发送的

时间:2014-03-17 18:05:20

标签: macos email

我试图让我的iMac(10.9.2)上的sendmail / postfix正常工作。我有一个php web应用程序,我试图在本地测试,它需要发送邮件。

即使直接测试:

date | mail -s test myEmail@gmail.com

邮件永远不会到达,即使是垃圾邮件也是如此。在日志中,我看到大量的"操作超时"联系google / gmail的错误:

Mar 17 10:57:13 imac.helion3.com postfix/postfix-script[10924]: starting the Postfix mail system
Mar 17 10:57:13 imac.helion3.com postfix/master[10925]: daemon started -- version 2.9.4, configuration /etc/postfix
Mar 17 10:57:13 imac.helion3.com postfix/qmgr[10933]: 012175629F9F: from=<daemon@localhost.localhost>, size=352, nrcpt=1 (queue active)
Mar 17 10:57:16 imac.helion3.com postfix/pickup[10932]: 94BBF562A0B2: uid=501 from=<botskonet>
Mar 17 10:57:16 imac.helion3.com postfix/cleanup[10948]: 94BBF562A0B2: message-id=<20140317175716.94BBF562A0B2@localhost>
Mar 17 10:57:16 imac.helion3.com postfix/qmgr[10933]: 94BBF562A0B2: from=<botskonet@localhost.localhost>, size=310, nrcpt=1 (queue active)
Mar 17 10:57:43 imac.helion3.com postfix/smtp[10937]: connect to gmail-smtp-in.l.google.com[74.125.25.27]:25: Operation timed out
Mar 17 10:57:46 imac.helion3.com postfix/smtp[10951]: connect to gmail-smtp-in.l.google.com[74.125.25.26]:25: Operation timed out
Mar 17 10:58:13 imac.helion3.com postfix/smtp[10937]: connect to alt1.gmail-smtp-in.l.google.com[74.125.193.27]:25: Operation timed out
Mar 17 10:58:16 imac.helion3.com postfix/smtp[10951]: connect to alt1.gmail-smtp-in.l.google.com[74.125.193.27]:25: Operation timed out
Mar 17 10:58:43 imac.helion3.com postfix/smtp[10937]: connect to alt2.gmail-smtp-in.l.google.com[74.125.196.26]:25: Operation timed out
Mar 17 10:58:46 imac.helion3.com postfix/smtp[10951]: connect to alt2.gmail-smtp-in.l.google.com[74.125.196.27]:25: Operation timed out
Mar 17 10:59:13 imac.helion3.com postfix/smtp[10937]: connect to alt3.gmail-smtp-in.l.google.com[173.194.76.27]:25: Operation timed out
Mar 17 10:59:16 imac.helion3.com postfix/smtp[10951]: connect to alt3.gmail-smtp-in.l.google.com[74.125.29.26]:25: Operation timed out
Mar 17 10:59:43 imac.helion3.com postfix/smtp[10937]: connect to alt4.gmail-smtp-in.l.google.com[74.125.131.27]:25: Operation timed out
Mar 17 10:59:43 imac.helion3.com postfix/smtp[10937]: 012175629F9F: to=<myEmail@gmail.com>, relay=none, delay=689, delays=538/0.01/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[74.125.131.27]:25: Operation timed out)
Mar 17 10:59:46 imac.helion3.com postfix/smtp[10951]: connect to alt4.gmail-smtp-in.l.google.com[173.194.75.27]:25: Operation timed out

我已经完成了推荐的postfix perms命令:

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

我在日志中看到ipv6错误后配置了postfix以使用ipv4。这是为了在本地进行测试,所以我不介意。

我已配置php使用:

sendmail_path=/usr/sbin/sendmail -t -i

即使我目前的测试不涉及php。

1 个答案:

答案 0 :(得分:9)

似乎端口25被阻止(来自您的ISP或可能在您的端):

google.com[74.125.131.27]:25: Operation timed out

打开终端并粘贴:

(echo >/dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 opened" || echo "TCP port 25 closed"

这应指示您的机器上是否打开了端口25。如果端口关闭,您显然需要打开它。

另一个有用的命令是:

sudo lsof -i -P | grep -i "listen"

这将指示当前处于活动状态的所有打开端口和连接。

由于您尚未提供有关配置本身的任何信息,因此我只能推测您的中继主机设置为什么。如果是谷歌,请尝试将端口设置为587

relayhost = smtp.gmail.com:587

ISP默认阻止端口25,因为垃圾邮件发送者常常使用它。

  编辑:确定必须采取两件事   考虑这种情况:

     
      
  1. postfix mailserver使用动态ip
  2.   
  3. 邮件服务器托管有阻止端口25的ISP
  4.         

    修复是使用中继服务器,其中涉及更新后缀   main.cf添加了中继主机信息和认证   标志。默认提交端口已更改为使用587绕过isp块。