macos - Sendmail/postfix 邮件无法从本地 Mac OS X (Mountain Lion) 发送

标签 macos email

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

即使直接测试:

日期 |邮件 -s 测试 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。

最佳答案

端口 25 似乎被阻止(无论是来自您的 ISP 还是可能在您这边):

google.com[74.125.131.27]:25:操作超时

打开终端并粘贴:

(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"

这将指示当前事件的所有开放端口和连接。

由于您没有提供有关您的配置本身的任何信息,我只能推测您的中继主机的设置。如果是 google,则尝试将端口设置为 587:

relayhost = smtp.gmail.com:587

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

EDIT: It was determined that two things had to be taken into consideration for this scenario:

  1. The postfix mailserver was using a dynamic ip
  2. The mailserver is hosted with an ISP that blocks port 25

The fix was to use a relay server, which involved updating the postfix main.cf with the additions of the relay host information and authentication flags. The default submission port was changed to use 587 to bypass the isp block.

关于macos - Sendmail/postfix 邮件无法从本地 Mac OS X (Mountain Lion) 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22461966/

相关文章:

linux - 如何根据文件类型复制文件

objective-c - NS面板: double animation

PHP mail() 在收到 ajax POST 请求时不起作用

html - CSS 为电子邮件绘制向下箭头(mail.google.com 问题)

python - 将 postfix 邮件集成到我的(python)webapp

node.js - Nodejs 从不存在的电子邮件发送电子邮件

perl - Perl Gmail电子邮件脚本错误

macos - 需要 AVPlayerView 在按下 esc 按钮时退出全屏

objective-c - NSScrollView 内的 NSImageView 平铺在缩小时绘制不需要的边框

ios - 安装失败: Invalid Argument - System Error