Integration between Unix mail and modern email services?

I enjoyed @ace’s writeup of the issue about copying phone numbers from Contacts. But having already followed the discussion about it here, the most intriguing part of the article for me was this (look at the second line):

@ace, have you somehow integrated Unix mail with your Gmail account? Or are you using Unix mailbox for something else? I’m not sure how I’d use this, but as I say, I’m intrigued!

This message means something is in your local mail spool (/var/mail/username). If you type mail, you can read and delete that mail.

You can send mail to yourself (or any other user on your local Mac) by typing mail username. Type in a subject line when prompted. Then type your message. Type Ctrl-D to end the message. You may see an error message from the internal mail daemon, but it will be delivered if the recipient is on the same Mac. He will then see that “You have mail” message at each login until the message is read.

Now, if you want to send mail to a different computer (e.g. or if you want to receive mail from another computer, then that will require some system configuration. You’ll need to find out what daemon your Mac is running. My Macs (running Sierra and Big Sur) seem to be running Postfix. I assume you can configure it the way you would on any other Unix-like system, but I’m going to stop here, because I haven’t done it and I don’t know what exactly is involved.

And, of course, if you want to actually receive mail from the Internet, then you are going to require a domain and a DNS MX record so the rest of the Internet will know where your server is, and your server will need to be Internet-reachable (meaning your firewall and your ISP must permit the inbound SMTP traffic).

And if your want your mail to be accessible to normal mail clients (and not just old tools designed for the local spool), you will want to be running an IMAP server as well. Another thing that is well beyond the scope of this comment. :slight_smile:

cron jobs can send log files to the local mail spool – and that would produce the “You have mail” prompt.


Thanks for the explanation, though I was assuming (maybe wrongly) Adam isn’t using mail to pass messages between users on his Mac, or run a mail server. But @david_blanchard’s theory seems more likely than my assumption that he’s integrated Gmail with the local mailspool!

@david_blanchard for the win!

When I checked why there was mail waiting, it turned out to be (irrelevant?) cron job errors from SuperDuper.

1 Like

If you want to see those messages in a more timely manner, you can configure Postfix to be able to send Internet e-mail (via whatever SMTP server your ISP provides for this purpose) and then add a .forward file to your home directory containing an Internet e-mail address. Then, whenever your local account receives mail, it will get forwarded to a mailbox that you actually look at.

But configuring Postfix for this left as an exercise for the reader. Hopefully, it’s simpler than configuring sendmail (which I’ve done in the past), which should be the textbook definition of an interface that requires a degree in computer science to figure out.

I’ve still never done it before, but I found these two links that seem to describe the process:

The procedure is (in quick summary):

  • Configure SASL with your SMTP server’s credentials (server address/port, user ID and password), since no legitimate mail service today runs an open mail relay.

    Note that this won’t work if your mail server requires OAuth or 2FA, since this mail-sender needs to run in a non-interactive fashion. You may have to enable/configure support for “less secure” mail clients using whatever mechanism that server requires. This may also prevent you from using mail servers that don’t offer such an access mechanism.

  • Add configuration to Postfix to specify the upstream mail server, that you are using SASL, and that you need TLS nework connections.

  • Start/restart Postfix

Much much easier than doing this with Sendmail. :slight_smile:

I’m not entirely sure why both of these articles ask you to configure Postfix to send everything through a single upstream mail server (e.g. GMail), instead of sending directly the server specified but the recipient’s DNS MX record. I assume this is due to spam-blocking filters where recipients’ mail servers may only accept mail from known-good source servers.

1 Like

you will want to be running an IMAP server as well. Another thing that is well beyond the scope of this comment. :slight_smile:

I used to do that back in the day…early aughts but it was a lot of hassle to maintain so gave it up.

The specific problem being that the “Mail Submission Program” on the system is /usr/sbin/sendmail, and programs such as cron invoke it at that exact path. So you want to make sure that when a program invokes sendmail, the mail arrives where you read it. Now on macOS this means configuring Postfix, because, sadly, Apple does not give you control over what /usr/sbin/sendmail actually is, since the Sealed System Volume that now makes it infeasible to change it without breaking the system update process. If it had been a Mail Transfer Agent of your choice, possibly one as simple as a command-line front-end to SMTP that just instantly and without queueing squirts the message at a configured SMTP server (there are quite a few of them now, like ssmtp, msmtp, or esmtp) then this job would be a whole lot easier. But, fortunately, although Postfix is no longer my favourite for simple jobs like this (I now endorse OpenSMTPD), it is still among the nicest to configure. All the docs for that version are on the system already, and the configuration is quite well-commented, so you can get it going fairly quickly.

Oh, no. I liked Sendmail! :slight_smile:

I chose to use Sendmail voluntarily, of all the available options, in 2004, when other options were well past maturity. Of course it was complex, but that also meant flexibility. (Exim probably comes closest to this now, in some respects, without sacrificing features for the modern era, but it was not, at the time, nearly as featureful.) In fact, if you avoided the m4 macros, probably you could whip up a hand-written cf for Sendmail today (which, yes, I enjoyed doing too back then, because I’m such a masochist) that just did the work necessary for submission to another system, without a daemon running, and you could use cron or launchd to get a queue runner for those messages that don’t make it. Mmm, and it would probably be quite easy to understand too …