Q. How do I block [email protected] or IP address for Sendmail spammers?
A. Sendmail offers various options to block an email address, domain name or IP address using access database.
File /etc/mail/access act as an access control for your Sendmail smtp server. With this file you can define:
- Who we accept mail from
- Who we accept relaying from
- Who we will not send to etc
# vi /etc/mail/sendmail.cf
Make sure following line exists in your configuration file (otherwise you need to add/append following line):
Save the file and exit to shell prompt. Now, open /etc/mail/access file:
# vi /etc/mail/access
To block junk or spam mail use following format
[email protected] REJECT
Save the file. Once sendmail.mc or access file is modified, you need to regenerate /etc/mail/sendmail.cf or rebuild the access database. Type any one of the following commands:
# cd /etc/mail
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Restart the sendmail:
# /etc/init.d/sendmail restart
Other options supported by access database
- OK – Accept email FROM: or TO: specified address
- DISCARD – Do not accept email FROM: or TO: specified address
- REJECT – Drop email with an error FROM: or TO: specified address
- HATER – Use check_mail and check_realy rules for email
- FRIEND – Do not use check_mail and check_realy rules for email
- ERROR:ecode:etext – Drop email with specified error code (ecode) and error text message (etext).
How do I test access database is working or not?
Use sendmail with -bt option as follows:
# sendmail Ã¢â‚¬â€œbt
> check_mail [email protected]
OR use telnet command:
# telnet localhost 25
MAIL FROM:[email protected]
In both case you should get relay denied error.