Enabling Postfix smtp email on Mac OS X 10.5 Leopard
Mac OS X comes with Postfix, which is the program behind mail and sendmail that handles all email incoming and outgoing. The below is what works for me on my Mac OS X 10.5 Leopard, and I'm here to summarize it to help people and also help my own memory.
Essential Section - the following shows the minimal settings to get it working
1a. Configure the domain, SMTP server and authentication settings:
edit /etc/postfix/mail.cf and append the following at the end:
myhostname = www.yourdomain.com
mydomain = yourdomain.com
relayhost = smtp.yourisp.com
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_passwords
2b. Create the hashed SMTP password file:
Create /etc/postfix/smtp_sasl_passwords with the following contents:
smtp.yourisp.com username:password
Run the following command to generate the hashed SMTP password file:
$ cd /etc/postfix
$ chmod go-rx smtp_sasl_passwords
$ postmap smtp_sasl_passwords
3. Finally, test whether the email works:
Enter either one of the following at the terminal:
$ echo "message" | mail -s "subject" recipient@yourdomain.com
$ printf "Subject: subject" | sendmail -f sender@yourdomain.com recipient@yourdomain.com
Then check the log file for success or failure:
$ tail /var/log/mail.log
Optional Section - the following shows the optional settings only use if necessary
4. To make the mail server autostart during bootup:
Modify /etc/hostconfig, add the following line:
MAILSERVER=-YES-
Modify /System/Library/LaunchDaemons/org.postfix.master.plist, add the following line before the closing tag:
<key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/>
Try to start service with:
$ sudo launchctl
launchd% start org.postfix.master
Check that Postfix is running:
$ telnet localhost 25
5a. If your SMTP server support TLS and you want to enable it:
edit /etc/postfix/mail.cf and append the following at the end:
smtp_use_tls = yes
smtp_enforce_tls = yes
smtp_sasl_tls_security_options =
smtp_sasl_tls_verified_security_options =
smtp_tls_loglevel = 2 # optional, log TLS negotiation in /var/log/mail.log
smtp_tls_per_site = hash:/etc/postfix/smtp_tls_sites
tls_random_source = dev:/dev/urandom
5b. Create the hashed TLS password file:
Create /etc/postfix/smtp_tls_sites with the following contents:
smtp.yourisp.com MUST_NOPEERMATCH
Run the following command to generate the hashed TLS password file:
$ cd /etc/postfix
$ postmap smtp_tls_sites
Remarks:
It is not necessary to modify the "sendmail_path" variable in php.ini, the default value "sendmail -t -i" should works fine.
