Serving on OS X: Postfix

Friday, May 06 2005 @ 05:01 PM EDT

Contributed by: Admin

This guy has an absolutely incredible, pretty detailed list of explainations on how to do all kinds of neat things with a Mac: web serving, MySQL, weblogs, etc. The one thing he stops short on is Postfix.

Postfix is the mail server that comes with OS X Panther and Tiger. (OS X 10.0-10.2 (Jaguar) came with sendmail.) With it you can do many cool things. If a web app you're running has an email notification feature, you'll need a mail server to use it. (You might be able to use your ISP's mail server for this, but running your own is, you know, cooler. :-) )

Having a mail server running lets you do many other cool things. There is a commandline program called 'mail' that accepts standard input and turns it into an email. So, you can say something like uptime | mail -s "server uptime" and you will get an email message* with the subject "server uptime" and the output of 'uptime' (something like "17:06 up 8 days, 6:33, 2 users, load averages: 0.06 0.10 0.11 ") will be the body of the message. Want to get an email every day telling you that the nightly backup you have scheduled with CRON worked? This is a way.

In any case, that guy's series is pretty great, but like I said, he stops short with the Postfix setup. He suggests using a shareware app to configure it and leaves it at that. I would much prefer knowing a bit more about the process. I have Postfix working on this Mac right now. However, it'll take a little time to figure out what I did--I set it up a while ago but left it in a non-working state and didn't even know it was working until after I rebooted** and noticed it was working. (I went to show someone the error message I got when I tried to send a message but poof!, it worked!) So, I don't have my notes of what I did handy. No fear, I'll just retrace my steps and document it as I go this time. This article will be completed later. I just wanted to kill a few minutes and get it started now. Check back again soon...

* you may or may not get the message. Due to things I'll explain in detail later, many ISPs will consider mail coming from a non-registered (for lack of a better term) mail server to be SPAM. However, there should be a way to set your box up properly so that this doesn't happen and hopefully I'll find the answer soon--after all, there should be no difference between an email your box automagically sends and one you send yourself through your regular email program.

** The grande olde UNIX tradition says that rebooting is only for hardware and kernel changes. That is, if you make a change to, say, your webserver, you shouldn't need to reboot your whole box, just restart the webserver application itself. Well, as I was setting up Postfix, I kept restarting the Postfix process and it kept not working. However, one of the related changes I made must have been tied to another service that I didn't restart, thus Postfix never worked. However, after rebooting the box, Postfix worked. So, I'll try to also figure out what other services I was affecting. Otherwise, my instructions will include "reboot" as a step. BTW, there's no real shame in rebooting, it's just a challenge to see if you can get something working without doing it. It also demonstrates your knowledge of what you're doing if you can make changes, restart the services, and have them work. However, there is a very good reason that you should reboot after making changes: in real life, it's very important to know that, as part of a proper configuration, the service you want comes up at boot time. It doesn't say much of your 7337 configuring sk1llz if you can get a service up and running but forget to set it to come on at boot time.