Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sendmail in Mac OS X Yosemite

I use the XAMPP stack for web development. I followed this tutorial a while ago to set my machine up to send mail from the localhost. This worked flawlessly under OS X Mavericks, but Yosemite seems to have broken it.

I have tried all of the troubleshooting methods in the linked post to no avail and created this small PHP file in order to test them. This outputs false on my machine.

<?php
    error_reporting(-1);
    ini_set('display_errors', 'On');

    $headers = array("From: [email protected]",
    "Reply-To: [email protected]",
    "X-Mailer: PHP/" . PHP_VERSION
    );
    $headers = implode("\r\n", $headers);
    $didhappen = mail('[email protected]', 'test', 'test', $headers);

     if($didhappen) {
        echo 'true';
     } else {
        echo 'false';
     }
?>

I can still send mail using the terminal, for instance, if I run the command mail [email protected] my machine will send the email from my personal gmail address (the one I configured for the localhost) and it would show up in [email protected]'s inbox. However, whenever I use the mail function in PHP the emails never arrive and are maybe never sent.

I think the problem lies within sendmail, It has generated some crash reports like this...

10/19/14 6:42:09.407 PM ReportCrash[13377]: Saved crash report for sendmail[13376] version ??? to /Library/Logs/DiagnosticReports/sendmail_2014-10-19-184209_Trevors-MacBook-Pro.crash

Any ideas on what Yosemite might have broken? Or has anyone else had this problem?

like image 741
Trevor Hutto Avatar asked Oct 19 '14 22:10

Trevor Hutto


2 Answers

I think, on the apachefriends forum, there is a solution for XAMPP on Yosemite.

For Reference, the directions on this link above are the following, which worked for me:

Edit your /Applications/XAMPP/etc/php.ini file

Look for ";sendmail_path"

And write the following:

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

like image 110
Torben Avatar answered Oct 26 '22 12:10

Torben


After several attempts of trying to reinstall XAMPP I finally trashed it and went with the native environments that Mac OS X offers. I followed this tutorial and was able to get Apache, PHP, MySql and PHPMyAdmin up and running on my machine without XAMPP.

I'm afraid the days XAMPP are over for me.

The PHP mail function now works after following the tutorial, so it must have been a problem with XAMPP this entire time.

like image 24
Trevor Hutto Avatar answered Oct 26 '22 14:10

Trevor Hutto