I inherited a Mountain Lion Server system that hosts a PHP web app. Among the things this app does is send email using the php
mail() command, which executes the sendmail binary. In addition to being able to do this, from the command line you can send email using /usr/bin/mail, in the standard way, and logging appears in /var/log/mail.
The weird thing is that there is no SMTP server running -- telnetting to localhost, port 25, fails. If you go to the mail option in the server app, the switch is in the OFF position. If you slide it to ON, the PHP app still send mail, /usr/bin/mail still sends mail, and now telnet to port 25 connects and reveals an attentive SMTP server.
In the course of trying to figure out who was doing what, I went to the Postfix docs:
which point out that the location for the Postfix config file is in /etc/postfix, which proved to be the case. Examining /etc/postfix/main.cf turns up this gem:
config_directory = /Library/Server/Mail/Config/postfix
Navigating to that directory reveals all the same config files as in /etc/postfix.
So my question, broadly, is how to untangle all of this? If Mail is switched off in the server app, how is it getting sent? Postfix is being started, but by who? And when and why do each of these Postfix config directories get consulted? I'm confused by all of these redundant behaviors and configurations, and I haven't even gotten to my actual question, which is to configure the mail gateway the sent email is getting routed to.
Can anyone shed some light on how this all fits together?