Search This Blog

Thursday, May 20, 2021

Postfix Autostarts and delivers local mail

I had a Mac Folder action setup to call a shell script.  Within the shell script is a mail -s command send send an email out.   The problem is that a normal unix-based system, such as the MacOS, doesn't have a mail system running to help you deliver mail.   However, it comes pre-installed with Postfix and a simple edit to:
/private/etc/postfix/main.cf

with the line:
relayhost = smtp.myabcdomain.com

is all it takes.   But I thought I had to do more.  I ran the mailq command and it said "Queue report unavailable - mail system is down".  I ran netstat -a -n |grep 25 and saw nothing LISTENing on port 25.

To my surprise, just running the mail -s command to send an email will automatically start the service, listen on port 25, delivery the mail, then shut down the postfix service automatically.  Knowing that, then I'm good. This saves me from learning how to permanently start postfix daemon and I don't care about bounce back messages as the smarthost will handle that.

Here you can see the mailq command works fine just after sending an email. and Port 25 will close after about 30 seconds.