The Issue
Sometimes we need to send email from a device/server directly without a proper domain/valid domain name. However when using mailcow, we can’t receive such email at all, they wont even hit Rspamd (rejected at postfix level)
The Workaround
Chance are it is because postfix is configured to not to deliver emails with a sender which has invalid/non-exist domain name. While there are many ways to fix this, here is one simple workaround, however it will effect the whole mailcow server (In simple term, all spam/phishing emails without a valid domain will be able to send email to us and get’s delivered into our mailbox).
1 On the mailcow server, we need to edit the postfx master.cf configruation file
nano /opt/mailcow-dockerized/data/conf/postfix/master.cf
Find the line
-o smtpd_sender_restrictions=permit_mynetworks,reject_unlisted_sender,reject_unknown_sender_domain
2 Remove reject_unknown_sender_domain
So we now have
-o smtpd_sender_restrictions=permit_mynetworks,reject_unlisted_sender
Ctrl + X, Y, Enter key to Save and Exit
3 Restart postfix container
docker compose restart postfix-mailcow
4 Now try again, we should be able to receive emails from senders with invalid domain.
Note
Removing reject_unknown_sender_domain will cause postfix deliver all incoming emails without a valid domain, that means besides our own emails without a valid domain, we will also be receiving all spam/malicious emails without a valid domain sending to our inbox.