It would be nice to reject incoming emails which use one of my virtual domains as sender address while not being a legitimate user of mine.
I know that I can reject incoming emails which use an existing alias/account name using smtpd_sender_restrictions=reject_sender_login_mismatch
, this does however still allow attackers to use a non-existant emailaddress with one of my virtual domains. (Which is favored in regards to spam detection).
What's the best way to reject incoming mails which use one of my virtual domains and aren't authenticated to do so?
SPF as well as DKIM are set up but configured to SoftFail, due to problems with mailinglists and forwards. I am not looking for SPF or DKIM but a solution for the postfix server that is the MX of the aforementioned domains.
I found two possible methods, but maybe there is a better way.
1st method:
Now I modified my
smtpd_sender_login_maps
to return an entry ofadmin
if the domain exists in the domains table. This way a record is returned, even when the emailadress doesn't exist as maibox/alias, but not when a foreign domain is the from address.2nd method:
This approach uses a
check_sender_access
lookup which returns a reject action if the domain is a virtual one and the user is notsasl_authenticated
.mysql_reject_virtual_domains.cf
:3rd method (thanks to masegaloeh):
I don't know how many cpu-load/SQL-queries reject_unlisted_sender generates, as it checks quite many things:
Request that the Postfix SMTP server rejects mail from unknown sender addresses, even when no explicit
reject_unlisted_sender
access restriction is specified. This can slow down an explosion of forged mail from worms or viruses.An address is always considered "known" when it matches a virtual(5) alias or a canonical(5) mapping.
The righteous way is to setup SPF for your domain and enable SPF in the MTA. Then you'll get protection not only for your own domain forging but also for all other domains having SPF enabled.
You should try to implement at least one of the followings (both is better):
Yet another 1st method with separate query without unions: