Emailing from PHP on Mac OS X
When my daughter wanted to have her web site include Flash-based form submission software I needed to make sure that PHP on frosty, my iMac running OS X 10.3, would be able to email out properly. As I found out, 10.3 is not set up to allow this, but it's easy enough to configure once you know how. I Googled the problem and found most of the answer, but there was one line missing and that turned out to be a critical line for the forwarding of emails while in a PHP script. The low-down is that you just need to properly configure postfix on the box, as it's already installed and most of the work is already done for you. So here goes:
First, look at /etc/hostconfig and make sure that there is a line that reads:
MAILSERVER=-AUTOMATIC-
Next, you need to edit the file /etc/postfix/main.cf and make sure it has the following lines:
... myhostname = frosty.themanfromspud.com ... mydomain = themanfromspud.com ... myorigin = $mydomain ... inet_interfaces = all ... mydestination = $myhostname, localhost.$mydomain ... mynetworks_style = subnet ... relayhost = smtp.comcast.net ...
and then you need to uncomment the line in the file /etc/postfix/master.cf to look like:
smtp inet n - n - - smtpd
At this point, if you restart your box, the email will send out from the host to any email address on the net. This is also very helpful in that my crontabs are now able to send me email off the box and this makes it a lot easier to keep track of them.
I've done this on Mac OS X 10.3 and 10.4 and it works great on both. I just wanted to write this into the journal before I forgot how to do it in the event that I need to do it again.