Topics

Configure sendmail to accept emails only if “from”, “to” or specific field matches

you can exclude an email address or even a host that is spamming you using the access file located in your etc directory, the bad news is that it does not support regex or even wildcards.
What I needed to achieve here is disabling all outgoing mail unless the To: field matches some email…here’s how to do that:
edit you submit.cf file in your /etc/mail dir

HHeader: $>Ruleset

HTo: $>CheckTo
D{Email}[email protected]
D{www}www
D{root}root

SCheckTo
R${www}							$@ OK
R${root}							$@ OK
R$*@gadelkareem.com		$@ OK
R${Email}		$@ OK
R$*	$#error $: 552 Ha2aw aw aw..... TOZ!

HCc: $>CheckTo

so any message going to another mail would be blocked and sent to postmaster with that error “552 Ha2aw aw aw….. TOZ!”
you can use regex as long as you follow sendmail manual.
the use of submit.cf here is because of the fact I do not use sendmail to recieve any emails, however if you like to do the block from the outside world you can use sendmail.cf to do the job.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close