Stop spam on sendmail

Lately the number of spam messages has grown very rapidly on my organization's sendmail server. There's a few things you can do. Here are two which helped considerably:

  1. Deny access to the domain: You can add the domain name to /etc/mail/access followed by the word REJECT. After editing the access file, you have to run make on the /etc/mail directory.

  2. Use online spam blacklists: There are many of these lists, such as Spamhaus ROKSO, Spamcop, or the Open Relay Database. These are organizations that basically provide a list of spammers. Many thanks to all of you!. To use their lists on sendmail, add the following lines to your /etc/mail/sendmail.mc file before the MAILER lines:

FEATURE(`dnsbl',`relays.ordb.org', `Rejected - see http://ordb.org/')dnl
FEATURE(`dnsbl',`bl.spamcop.net',`Rejected - see http://spamcop.net/')dnl
FEATURE(`dnsbl',`sbl.spamhaus.org',`Rejected - see http://www.spamhaus.org/')dnl

After editing sendmail.mc, you have to rebuild sendmail.cf. Here's how I did it:

$ cp /etc/mail/sendmail.mc .
$ m4 ../m4/cf.m4 sendmail.mc > sendmail.cf
$ cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.BAK
$ cp sendmail.cf /etc/mail/sendmail.cf
$ cp: overwrite `/etc/mail/sendmail.cf'? y
$ /etc/rc.d/init.d/sendmail restart

Any more ideas to stop spammers? I honestly do not understand why these people keep spamming. Problems man, serious problems! Don't they realize that there is no way people will read their emails, not to mention buy their products or fall for their scams? Or will they?

Tagged as: howto, admin, spam, sendmail
Fork me on GitHub