I found this here: http://jspr.tndy.me/2008/05/php-mail-and-osx-leopard/ Credit goes to him:
There are 4 files I used for the following:
- php.ini (this could be anywhere depending on your installation, mine’s in /usr/local/php5/lib/)
firstly, sudo nano -w /etc/hostconfig and add the following line:
then sudo nano -w /etc/postfix/main.cf, find the myhostname variable (by default it’s host.domain.tld), uncomment it and change it to your domain (if you’re on a machine that doesn’t have a DNS, you can make it a domain that you’re responsible for so that it doesn’t get shut down at the receiving end, but please don’t make it google.com or something like that!)
now, open php.ini and look for the sendmail_path variable, uncomment it, make its value sendmail -t -i, save then restart apache. I’m not really sure if this is 100% necessary as there’s a comment above that says this is the default value anyway, but it can’t hurt!
now open a terminal window and execute the next couple of commands:
% sudo postfix start
% tail -f /var/log/mail.log
finally, create a file called mail.php (or whatever!) and add the following to it:
'email@example.com', // your email address
'Test', // email subject
'This is an email', // email body
"From: Me <firstname.lastname@example.org>rn" // additional headers
obviously replace email@example.com with your email address and firstname.lastname@example.org with a valid email address (domain at least, as some mail servers will bounce your email if the sender’s domain isn’t real). Now navigate to your mail.php file (likely http://localhost/mail.php) and watch your terminal window to see that it’s been sent successfully. If it hasn’t, let me know if you fixed it and I’ll update this – it’s annoying to me that there isn’t really an answer to this question that I can find so the more comprehensive this is, the more helpful!.