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/ If not, you will need to add/append following line and Save the file.


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. REJECT REJECT REJECT

Step 3 :-

Once you modified or access file, you will need to regenerate /etc/mail/ or rebuild the access database. You can use any one of the following commands to do the same:

cd /etc/mail


m4 /etc/mail/ > /etc/mail/

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 ERROR:550:Relay denied REJECT REJECT
Spam:abuse@ FRIEND
Connect: ERROR:5.7.1:550: Relay denied


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, 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 *