How to block spam email address or IP address for Sendmail spammers
Sendmail offers various options to block spam email address, domain name or IP address using access database.
The File /etc/mail/access will act as an access control for your Sendmail smtp server. Using this file you can define
- Who we accept mail from
- Who we accept relaying from
- Who we will not send to etc
Step 1 :-
You will need to check and make sure the following line exists in your sendmail configuration file /etc/mail/sendmail.cf. If not, you will need to add/append following line and Save the file.
To block junk or spam mail, you can use following format and add required entry to the file /etc/mail/access and save the file.
email@example.com REJECT 192.168.1.105 REJECT 22.214.171.124/255.0.0.0 REJECT
Step 3 :-
Once you modified sendmail.mc or access file, you will need to regenerate /etc/mail/sendmail.cf or rebuild the access database. You can use any one of the following commands to do the same:
cd /etc/mail make OR m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Step 4 :-
Restart the sendmail
The below options are also supported by access database
- OK for Accept email FROM: or TO: specified address - DISCARD for Do not accept email FROM: or TO: specified address - REJECT for Drop email with an error FROM: or TO: specified address - HATER for Use check_mail and check_realy rules for email- - FRIEND for Do not use check_mail and check_realy rules for email - ERROR:ecode:etext for Drop email with specified error code (ecode) and error text message (etext).
Examples example.com ERROR:550:Relay denied FROM:firstname.lastname@example.org REJECT TO:email@example.com REJECT Spam:abuse@ FRIEND Connect:126.96.36.199 ERROR:5.7.1:550: Relay denied
752 total views, 14 views today