5

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: from@example.com",
    "Reply-To: replyto@example.com",
    "X-Mailer: PHP/" . PHP_VERSION
    );
    $headers = implode("\r\n", $headers);
    $didhappen = mail('myemail@email.com', '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 example@gmail.com my machine will send the email from my personal gmail address (the one I configured for the localhost) and it would show up in example@gmail.com'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?

Trevor Hutto
  • 2,112
  • 4
  • 21
  • 29
  • @JohnConde I don't think this is a duplicate, it deals specifically with OS X Yosemite. – Trevor Hutto Oct 19 '14 at 22:41
  • 1
    @JohnConde this question actually have nothing to do with PHP – Bryan Chen Oct 19 '14 at 22:42
  • Thank you @BryanChen. They are so quick to close things sometimes, I have a feeling a lot of people may be having this very problem Monday morning. – Trevor Hutto Oct 19 '14 at 22:47
  • It will be nice to reword your title & question to remove the PHP part since it is all about sendmail – Bryan Chen Oct 19 '14 at 22:49
  • @TrevorHutto: I would still consider this a duplicate. If you can send mails from the CLI, it's got nothing to do with sendmail itself. Also, if you think that it's not a duplicate, you should indicate why the answer in the linked post doesn't solve the problem for you. – lxg Oct 19 '14 at 23:11

2 Answers2

16

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"

Community
  • 1
  • 1
Torben
  • 161
  • 2
6

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.

Trevor Hutto
  • 2,112
  • 4
  • 21
  • 29
  • I tried to do the same and have a working Apache, PHP and MySQL without XAMPP now. Still, I'm having some trouble to get sendmail working. How did you do it exactly? Did you use postfix again and configure it as described in the first link in your question? – jakob.j Oct 22 '14 at 20:52
  • Got it. Had to do the following (also seems to be new with Yosemite): http://stackoverflow.com/questions/26447316/mac-os-x-10-10-yosemite-postfix-sasl-authentication-failed – jakob.j Oct 22 '14 at 22:07
  • Just for reference, the instructions in the other answer work with XAMPP on Yosemite. No need to change your setup. I prefer having an isolated/separate dev environment from my OS. – Ryan Jan 13 '15 at 18:42