Mac OS X 10.10 Yosemite 邮件服务器(Postfix) SASL身份验证失败

36

我按照下面链接中描述的步骤设置我的Mac以发送电子邮件。 http://www.anujgakhar.com/2011/12/09/using-macosx-lion-command-line-mail-with-gmail-as-smtp/

在我的Mac OS X 10.9上一切正常。但是在升级到OS X 10.10后,mail.log显示了以下错误。问题出在哪里?

Oct 19 00:28:22 paullam-macbook-pro.local postfix/smtp[30383]: 6B47B8AD4E8: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.68.109]: generic failure
Oct 19 00:28:24 paullam-macbook-pro.local postfix/smtp[30383]: 6B47B8AD4E8: to=<zzpaul@gmail.com>, relay=smtp.gmail.com[74.125.68.108]:587, delay=3.4, delays=0.01/0/3.4/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.68.108]: generic failure)
4个回答

97

我遇到了相同的问题。通过谷歌搜索找到了这个链接:http://hkitago.com/2014/09/yosemiteのpostfix設定/

事实证明,我在/etc/postfix/main.cf文件中缺少以下行:

smtp_sasl_mechanism_filter = plain

3
这让我费了好几个小时才找到,但是找到后解决得很快。太棒了! - mlantz
5
你们都会读日语吗?如果你们发现英语更容易阅读,可以尝试阅读这些说明:http://www.iamafishnow.com/2014/11/02/set-up-smtp-gmail-to-work-with-php-mail-on-osx-yosemite/。此外,我需要在我的Google账户中启用不太安全的应用程序访问权限:https://www.google.com/settings/security/lesssecureapps。一般情况下可能不是一个好主意,但否则Google将无法发送我的电子邮件。测试完成后,请关闭访问权限。 - bergie3000
谢谢@bergie3000,"不安全应用程序"选项是我缺失的拼图中的一部分。谢谢。 - Manachi
1
这个问题和使用Google应用程序密码让我在Sierra上开始工作。谢谢! - a. brooks hollar
1
如果有人收到了“SASL身份验证失败”或“需要特定于应用程序的密码”的错误消息,那么您可能在Google中使用了双重身份验证。请查看此教程以解决此问题(设置特殊应用程序密码):https://davidwesterfield.net/2015/02/using-postfix-sasl-authentication-with-google-2-step-verification-on/ - Hermann Schwarz
显示剩余2条评论

8

根据建议,我添加了两个代码片段,但仍然没有运气。然后我找到了这篇文章:

http://www.developerfiles.com/how-to-send-smtp-mails-with-postfix-mac-os-x-10-8/

并从中运行了以下步骤:

第二步。创建sasl_passwd文件 我们需要使用SMTP凭据创建sasl_passwd文件。

sudo vi /etc/postfix/sasl_passwd

请按照以下内容精确地写下(不要输入您的用户地址和密码)并保存:

smtp.gmail.com:587 your_address@gmail.com:password

从sasl_passwd文件创建Postfix查找表。

sudo postmap /etc/postfix/sasl_passwd

这将创建sasl_passwd.db文件。

步骤3. 重启Postfix 为了应用所有新的更改,我们必须重新启动Postfix:

sudo postfix reload

还是没有运气。但是我注意到 /etc/postfix/main.cf 中的 relayhost 被用括号注释掉了,像这样:
relayhost = [smtp.gmail.com]:587

我将此行更改为:

relayhost = smtp.gmail.com:587

重新加载了 postfix:
sudo postfix reload

并且 postfix 开始发送电子邮件。万岁!


4
你的回答有两个问题:1)在步骤“smtp.gmail.com:587 your_address@gmail.com:password”中,你必须输入你自己的地址和密码。2)在最后一步中,你拼错了“postfix”。此外,我发现了另一件事情,这实际上是解决问题的关键——你必须在你的Google账户中打开访问不安全应用程序(https://www.google.com/settings/security/lesssecureapps)。**请自行承担风险!** - bergie3000
非常好的链接。谢谢@esod。 - arcseldon
谢谢@bergie3000,这解决了我的问题。 - Manachi

2

结果我发现需要另外一个部件才能使这个工作起来。

sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

接着这个操作:

<dict>

添加这个:

<key>RunAtLoad</key>
<true/>

我现在可以在Yosemite上使用Postfix发送电子邮件了!

0

@Josh的答案(无法在答案上留下评论)很好用,但使用登录作为过滤器也可以很好地工作。不过,我不确定区别是什么。

正如文档页面所述。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接