简体   繁体   English

使用Postfix在Mountain Lion上发送电子邮件时的配置问题

[英]Configuration issue when sending email on Mountain Lion using Postfix

I've been stuck on this problem for the whole afternoon and tonight but cannot find an answer. 我整个下午和今晚都一直在解决这个问题,但找不到答案。 But I believe it's some easy configuration issue on Mountain Lion. 但是我相信这是Mountain Lion上一些容易配置的问题。

I want to send out email using PHP, and I installed PEAR:Mail package; 我想使用PHP发送电子邮件,并安装了PEAR:Mail软件包; that all works fine. 一切正常。

But when I try to send email in PHP, it returns me no error; 但是,当我尝试使用PHP发送电子邮件时,它没有返回任何错误。 but email not received. 但未收到电子邮件。

I further dig into the problem, found that I need to properly set up my local postfix mail program. 我进一步研究该问题,发现我需要正确设置本地后缀邮件程序。 I therefore following these articles to setup: http://benjaminrojas.net/configuring-postfix-to-send-mail-from-mac-os-x-mountain-lion/#comment-259 ; 因此,我将按照以下文章进行设置: http : //benjaminrojas.net/configuring-postfix-to-send-mail-from-mac-os-x-mountain-lion/#comment-259 ; when that didn't work, I followed that one instead: http://slashusr.wordpress.com/2012/02/14/enabling-postfix-for-outbound-relay-via-gmail-on-os-x-lion-11/ . 如果该方法不起作用,我会改用该方法: http : //slashusr.wordpress.com/2012/02/14/enabling-postfix-for-outbound-relay-via-gmail-on-os-x-lion -11 / The basic steps in the blog post is to teach you how to send out using GMail by doing some settings in /etc/postfix/main.cf 博客文章中的基本步骤是通过/etc/postfix/main.cf中的一些设置来教您如何使用GMail发送邮件

But when I test it in terminal with command: 但是当我在终端用命令测试它时:

date | mail -s test <my_email_address>

Nothing happened, except that when I type "mail" again, it prompted me with a new message, telling me this error (part, only what I think to be useful): 什么都没发生,只是当我再次输入“ mail”时,它以一条新消息提示我,告诉我该错误(部分,仅是我认为有用的错误):

: host smtp.gmail.com[209.85.225.108] said: 530-5.5.1 Authentication Required. :主机smtp.gmail.com [209.85.225.108]说:530-5.5.1需要身份验证。 Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 aa4sm11414435igc.15 (in reply to MAIL FROM command) 欲了解更多信息,请访问530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 aa4sm11414435igc.15(回复MAIL FROM命令)

--1306515822A0.1347279593/songyy.local Content-Description: Delivery report Content-Type: message/delivery-status --1306515822A0.1347279593 / songyy.local内容描述:传递报告内容类型:消息/传递状态

I visited the link given in the error message, but it's irrelevant. 我访问了错误消息中给出的链接,但这无关紧要。

I'll very much appreciate if anyone can give me some advice on this. 如果有人可以给我一些建议,我将不胜感激。

I want to send out email using PHP, and I installed PEAR:Mail package; 我想使用PHP发送电子邮件,并安装了PEAR:Mail软件包; that all works fine. 一切正常。

Very well. 很好。 Then you must have a "mail relay server" address, to whom mails get sent. 然后,您必须具有一个“邮件中继服务器”地址,邮件将被发送到该地址。 It is usually supplied by your Internet provider. 它通常由您的Internet提供商提供。

You must configure that address into Postfix, as relayhost . 您必须将该地址配置为Postfix,作为relayhost No other setting is usually necessary. 通常不需要其他设置。

The recipe you followed is much more complicated because it entails Postfix connecting to GMail and authenticating as a user, all through TLS/SSL. 您遵循的食谱要复杂得多,因为它需要Postfix连接到GMail并通过用户身份验证,而这些都是通过TLS / SSL进行的。 To do this you must store the username and password to your GMail account (or another account created for that purpose) in the postfix passwd file. 为此,您必须将用户名和密码存储到Postfix passwd文件中的GMail帐户(或为此目的创建的另一个帐户)中。

The fact that GMail complains of "Authentication Required" tells us that either you skipped this detail, or you stored the wrong password; GMail抱怨“需要身份验证”这一事实告诉我们,您跳过了此详细信息,或者存储了错误的密码; so GMail can't go through the email forwarding process. 因此GMail无法完成电子邮件转发过程。

Note that if you only use plain SMTP, the outbound emails will be sent in the clear (as opposed to GMail use of SSL encryption). 请注意,如果仅使用纯SMTP,则出站电子邮件将以明文形式发送(与GMail使用SSL加密相对)。

Check out the system logs if you need to see in detail what happened to your mails. 如果您需要详细查看邮件发生了什么,请查看系统日志。

Another thing to watch out, you say: 您需要注意的另一件事是:

I specified the file by setting: smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd 我通过设置指定文件:smtp_sasl_password_maps = hash:/ etc / postfix / sasl_passwd

This file expects to be in a specific format (documented in the file itself). 该文件应采用特定格式(在文件本身中记录)。 After that, though, you have to convert the file into the hashfile , which is the same filename but .db extension. 但是,此后,您必须文件转换为hashfile ,该文件名具有相同的文件名,但.db名为.db Some distributions do this automatically, otherwise you need to manually run the postfix utility postmap (or in a pinch, makemap ). 有些发行版会自动执行此操作,否则,您需要手动运行postfix实用程序postmap (或在需要时运行makemap )。 In your case: 在您的情况下:

postmap -c /etc/postfix /etc/postfix/sasl_passwd

This will take /etc/postfix/sasl_passwd and hash it into /etc/postfix/sasl_passwd.db , which is the actual file Postfix checks . 这将使用/etc/postfix/sasl_passwd并将其哈希到/etc/postfix/sasl_passwd.db这是Postfix检查的实际文件 It is possible that this particular detail was not covered in the tutorial you followed, and Postfix is still checking a .db file which was built from the previous (and empty!) sasl_passwd . 您遵循的教程中可能未涵盖此特定细节,并且Postfix仍在检查从先前(且为空!) sasl_passwd构建的.db文件。

You are quite right that by specifying user, host and pass in PEAR, you are effectively overriding Postfix configuration - I think the Mail package performs so-called direct-to-MX exchange, and thus does not even need Postfix at all. 完全正确,通过指定用户,主机和PEAR输入,可以有效地覆盖Postfix配置-我认为Mail包执行所谓的Direct-to-MX交换,因此甚至不需要Postfix。

The log files should be specified in main.conf and are usually /var/log/messages or /var/log/mail(.something) . 日志文件应在main.conf中指定,通常为/var/log/messages/var/log/mail(.something)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM