How to block spam email address or IP address for Sendmail spammers

If you found this post helpful, kindly share it and show your support :)

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.

FEATURE('access_db')dnl

Step 2:-


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.

username@example.com REJECT
192.168.1.105 REJECT
202.45.1.100/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

/etc/init.d/sendmail restart

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:testmail@example.net REJECT
TO:spam@test.com REJECT
Spam:abuse@ FRIEND
Connect:202.54.1.2 ERROR:5.7.1:550: Relay denied

Loading

Mohammed Noufal

I'm Mohammed Noufal, working as Server Admin for the last 10 years.  In my day-to-day life, l had to face different problems related to Web-hosting. On my website Errorlogz.com, you can find solutions for different Web-hosting-related problems. Sometimes, I spent hours searching/googling to find a solution. This inspired me to start a website that gives solutions to different Webhosting problems. This website includes basic Linux and windows commands, and different control panels like cPanel, Plesk, DirectAdmin, Webmin & so on. You can find solutions and or suggestions for different Web-hosting related problems from here. Hence I would like to say Errorlogz is your server protector.  I will be glad if Logdetect can help any one of the Server admins to find a solution to his problem.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *