I need to do lots of local email testing (on macOS 10.14), so I use a fake SMTP server on port 2500 for most things, however, I also need to trap messages sent directly via a local sendmail
binary, and that really means using a real mail server that can relay them to my fake mail server. I'm attempting to use postfix for this, but it's really not going well. My aim is to have it relay all messages for all users in all domains, with no filtering, encryption, or authentication. I do not want it to pay any attention at all to local user accounts, and that seems to require disabling the local postfix delivery agent, and I've not found how to do that.
My config mostly comes down to this:
local_transport = local:$myhostname
mydestination = $myhostname, localhost.$mydomain, localhost
local_recipient_maps =
relayhost = localhost:2500
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/local_passwd
smtp_use_tls = no
smtp_tls_security_level = none
compatibility_level = 2
fallback_transport = localhost:2500
My fake mail server requires auth, though it doesn't check anything and any username or password will work, so there is a dummy entry in that local_passwd
file.
Seeing logs on macOS is extremely painful; the best approach I've found so far is:
sudo log stream --predicate '(process == "cleanup") || (process == "pickup") || (process == "qmgr") || (process == "error")' --info
When I submit messages directly to it using sendmail, I can see is that it's happy to accept messages to local accounts, but it doesn't relay them. It also rejects messages sent to non-existent accounts, like [email protected]
that I want it to accept and relay.
The messages end up in a mailbox somewhere that I can get to if I run mail
.
What have I missed?
I gave up on trying to use postfix for this and found msmtp, which is much simpler, and is available in homebrew.
I created a config file for it containing:
The changed
sendmail_path
in my php.ini:This works very nicely to provide a bridge between PHP's
mail()
function and the local SMTP testing app HELO.