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

hel*_*on3 8 email macos

我正在尝试让sendmail/postfix在我的iMac(10.9.2)上正常工作.我有一个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
Run Code Online (Sandbox Code Playgroud)

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

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start
Run Code Online (Sandbox Code Playgroud)

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

我已配置php使用:

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

即使我目前的测试不涉及PHP.

l'L*_*L'l 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"
Run Code Online (Sandbox Code Playgroud)

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

另一个有用的命令是:

sudo lsof -i -P | grep -i "listen"
Run Code Online (Sandbox Code Playgroud)

这将指示当前活动的所有开放端口和连接.

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

relayhost = smtp.gmail.com:587
Run Code Online (Sandbox Code Playgroud)

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

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

  1. 后缀邮件服务器使用动态IP
  2. 邮件服务器托管有阻止端口25的ISP

解决方法是使用中继服务器,其中包括通过添加中继主机信息和身份验证标志来更新后缀main.cf.默认提交端口已更改为使用587绕过isp块.