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.

I want to send out email using PHP, and I installed PEAR:Mail package; that all works fine.

But when I try to send email in PHP, it returns me no error; 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; 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/. 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

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):

: host smtp.gmail.com[209.85.225.108] said: 530-5.5.1 Authentication Required. 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)

--1306515822A0.1347279593/songyy.local Content-Description: Delivery report Content-Type: message/delivery-status

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.

Answers


I want to send out email using PHP, and I installed PEAR:Mail package; 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.

You must configure that address into Postfix, as 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. 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.

The fact that GMail complains of "Authentication Required" tells us that either you skipped this detail, or you stored the wrong password; so GMail can't go through the email forwarding process.

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).

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

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. Some distributions do this automatically, otherwise you need to manually run the postfix utility postmap (or in a pinch, 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. 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.

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.

The log files should be specified in main.conf and are usually /var/log/messages or /var/log/mail(.something).


Need Your Help

EMACS: Auto run a function when open a new buffer

emacs elisp text-editor emacs24

How can I auto run a function when open a new buffer, say text-scale-adjust.

REST - How to display certain getters in javax.ws.rs.core.Response Entity

java rest response

I was wondering if there are any ways to annotate Entity getters in such way that the ResponseBuilder will display only the ones which have that specific annotation.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.