I spent a lot of time of figuring out how to send mails through PHP mail() function on my new installation of Yosemite.

Things were weird because I was able to run the unix mail command from command line and it was working perfectly fine.

First lets check if this command works for you

date | mail -s testing username@domain.com

This should work out of the box in OSX (Yosemite), You wont need to configure any SMTP for this command to work. If you are not receiving any email with this, Check your unix mailbox under var/mail/{username}, many times Gmail just bounce back the email considering it as a SPAM.

In your php.ini file ( xamppfiles/etc/php.ini for XAMPP). Change the sendmail path to this

sendmail_path = "env -i /usr/sbin/sendmail -t -i"

Notice that env -i is important here, That was the part I was missing in my configuration and banging my head all the time. Save the file and restart your apache. mail() function should work for you absolutely fine.

If you want your SMTP to be changed to gmail ( since many email client might block you email from local machine domain)

Follow the instructions given in following link

http://jonathonhill.net/2013-04-19/send-mail-using-php-on-mac-os-x/

Comments