Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm debugging some mail related stuff on my Mac, and not quite sure how my system is even sending mail.

I can run a simple command like date | mail -s test myemail@mydomain.com and receive an email just fine. Cool. I can also use PHP's mail() function to send mail. PHP's sendmail_path configuration variable is /usr/sbin/sendmail -t -i, looks okay.

But the weird thing is I don't think Postfix is even running...

$ postqueue -p
postqueue: fatal: Queue report unavailable - mail system is down
$ ps -aef | grep -i postfix
  501 28403 25525   0  2:10PM ttys042    0:00.00 grep -i postfix
$ launchctl list | grep -i mail
-   0   com.apple.MailMigratorService
70829   -   0x7fa87941a060.anonymous.Mail
$ launchctl list | grep -i postfix
-   0   org.postfix.master

How is my Mac even sending mail from the mail terminal command if Postfix isn't running? Is there some other mail daemon OS X runs?

share|improve this question
3  
I don't know the details, but Postfix spawns when you use the mail command, and shuts down shortly afterward. Try mailing something and note you can reach Postfix on port 25 for a bit afterward, but not later. – zigg Aug 2 '13 at 18:18
    
Postfix is the default! It comes pre installed with osx. – Buscar웃 Aug 2 '13 at 20:12
    
Try disabling it with sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist – Buscar웃 Aug 2 '13 at 20:14

It is using postfix. At a high-level, when you execute the mail command, the following is happening:

  • Invoking mail drops your message as a file in the postfix maildrop directory, i.e., /var/spool/postfix/maildrop. This happens because mail calls sendmail which calls postdrop which puts the file in the maildrop.
  • The postfix main daemon, master is configured to startup when the maildrop has files in it. This is specified in the /System/Library/LaunchDaemons/org.postfix.master.plist file.
  • The master daemon starts other needed postfix processes such as pickup, qmgr and smtp to deliver the mail.
  • All these process including the master daemon die after being idle for period of time.

The postqueue -p command needs the showq daemon which will be started only when master is running. When that's not the case, you see that error. The showq daemon can be configured to always be running so that you can use the postqueue -p command. If you want to just see the mail queue, you can do this:

$ sudo postfix start && postqueue -p && sudo postfix stop

But note that if you start it this way, you must shut it down too. Otherwise the postfix master daemon will be resident and won't be on-demand anymore.

If you want to know which processes start after you issue mail, you can use the execsnoop command to see which process are starting up:

$ sudo execsnoop -v
STRTIME                UID    PID   PPID ARGS
2016 Apr 20 23:57:52   501   2358   1154 mail
2016 Apr 20 23:57:52   501   2359   2357 date
2016 Apr 20 23:57:52   501   2360      1 sendmail
2016 Apr 20 23:57:52   501   2367   2360 postdrop
2016 Apr 20 23:57:52     0   2369   2343 cleanup
2016 Apr 20 23:58:23     0   2384      1 master
2016 Apr 20 23:58:23     0   2385   2384 pickup
2016 Apr 20 23:58:23     0   2386   2384 qmgr
2016 Apr 20 23:58:24     0   2387   2384 bounce
2016 Apr 20 23:58:24     0   2388   2384 trivial-rewrite
2016 Apr 20 23:58:24     0   2389   2384 local
2016 Apr 20 23:58:24     0   2390   2384 smtp
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.