Matt Jones

before you play two notes learn how to play one note - and don't play one note unless you've got a reason to play it - Mark Hollis

Getting Sendmail to Work on Jaguar

OS X has, inbuilt, a piece of software called Sendmail. It’s one of these powerful programs that reside within the inner gubbins of OS X which can be made to do all sorts of powerful things using nothing else but the command line… if you’re a UNIX wizard that is (and I most certainly am not).

As its name implies, Sendmail is a tool for working with email. If you open a terminal window, you can type ‘mail matt@frownland.com’ followed by a subject and body text (adding a line-break and ’.’ at the end) and your email will be sent. Well that’s how it should work anyway, because Apple – apparently, for reasons of security – have stopped Sendmail from working in Jaguar (it works up to 10.1.4). Now why is this a problem? Why can’t I leave the UNIX nerds to worry about how they’re going to send their emails and get on with using good old Mail.app? Well, it’s a problem if, like me, you’re using your Mac to learn about PHP.

Mail() is a function used to send email from within a PHP application. On machines running UNIX or its derivatives (OS X included), this function uses Sendmail to handle any emails that are sent from a PHP script. This is configured in the php.ini file with the line:

sendmail_path = /usr/sbin/sendmail -t

However, even with this path properly set, the mail() function will not work because of the problem with Sendmail. What’s most annoying is that no error messages accompany the problem, so you’re left completely in the dark when the test email fails to appear in your Inbox.

The solution lies in doing a bit of reconfiguring of Sendmail and the instructions to do this can be found in this O’Reilly article.

If you’re wondering why I’ve written this technical – admittedly dull – post, it’s because I’ve spent all day trying to find the solution to this problem and if I can make someones life easier by publishing this information for Google to index, then I’m glad to have posted it.

Now… chimps.

6 Responses to “Getting Sendmail to Work on Jaguar”

  1. Tommy Says:

    Cheers Matt, just getting into the PHP thing myself and was wondering how to send e-mails via PHP. :)

  2. Stu Says:

    Me too, although I’ve got lots to do before I get to sending e-mail with it. Bring on the chimps!

  3. natis Says:

    you know, as great as an environment OS X is, I just never find myself doing much on it rather than just uploading my PHP and MySQL experiments onto one of two development servers that I have access to. I just can’t seem to find it in me to do anything else of OS X other than what I used to do in classic. I think it’s because of my fear of permissions. When I installed OS X in mid 2001, I played around so much with things that I screwed up the permissions so badly that I had to reinstall.

    –natis

  4. Kev Says:

    This may or may not be useful to anyone but a little while ago I wrote a php mail script for a friend. I know that there’s a lot of code in it that’s less than ideal, but I cut corners because I wanted it to be a very simple solution that could just be uploaded and used (the error catching is especially unsophisticated). Anyway, maybe looking at the code will help someone out.

    form
    source code

    Enjoy.

  5. Tommy Says:

    Thanks for that Kev, I’ll check that out when I’m sober. ;)

  6. Matt Says:

    Great script, thanks Kev. It’s made the one i’m using for my email form look particularly shoddy and half-baked.

Leave a Reply