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

  1.  
  2. HHeader: $>Ruleset
  3.  
  4. HTo: $>CheckTo
  5. D{Email}admin@gadelkareem.com
  6. D{www}www
  7. D{root}root
  8.  
  9. SCheckTo
  10. R${www}|>                                                       $@ OK
  11. R${root}|>                                                      $@ OK
  12. R$*@gadelkareem.com             $@ OK
  13. R${Email}|>             $@ OK
  14. R$*     $#error $: 552 Ha2aw aw aw….. TOZ!
  15.  
  16. HCc: $>CheckTo
  17.  

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.


Tags :

This entry was posted on Tuesday, April 22nd, 2008 at 4:17 am and is filed under Blog, Solutions. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 

Leave a Reply


 Top