I run cron jobs on my Mac laptop, and so I want the mail daemon to be able to send the output mail to my regular mail account. I've got that working (my local account has a
.forward file), but I'm often on networks where connecting to the destination's MX on port 25 doesn't succeed.
Therefore, I would like to have the local mail daemon send its outgoing mail, regardless of the destination, to another SMTP server (which happens to be a SSH port-forward to a server under my control). How do I configure the Apple-supplied Postfix to do this?
I tried setting
relayhost = [localhost]:40125 (where 40125 is the SSH port forward), but while I can now send mail to a proper Internet mail address (e.g.
firstname.lastname@example.org), cron job mail (which is addressed to
kpreid@<whatever the DHCP hostname is>) doesn't get delivered. From the one bounce I saw, it appears that this causes all mail, even for the local hostname, to go to the relayhost first.
Therefore, I need a way to relay to
[localhost]:40125 unless the address domain is this machine's domain (which varies frequently).