Adding a Spam Blacklist filter to your Sendmail config

Add the following line to you file use SpamCop’s email blacklist filter on your sendmail email server:

FEATURE(`dnsbl', `', `"Spam blocked see:"$&{client_addr}')dnl

Regenerate your sendmail config with:

m4 >

then restart your sendmail server with

. /etc/init.d/sendmail restart

To block individual domains:

  • Edit /etc/mail/access
    ...    REJECT    REJECT

  • Convert access to access.db
    makemap hash /etc/mail/access.db < /etc/mail/access
  • Restart sendmail
    # /etc/init.d/sendmail restart

Resolving “mail loops back to self” issues with Sendmail

If you are getting local email (to local users, eg root) bounced back with errors stating ‘mail loops back to self’, ensure that the hostname and domainname map to localhost and localdomain respectively:

hostname localhost
domainname localdomain

If you set these to be a hostname or domainname that you have for your MX DNS entry, this seems to give the error ‘mail loops back to self’

Sendmail Configuration Basics

Sendmail configuration should be done in the /etc/mail/ file

To generate configuration changes, use the m4 macro processor:

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

To restart sendmail after making changes:

/etc/init.d/sendmail restart

Define the domainnames for which your mail server handles mail for in the /etc/mail/local-host-names file. For example, if you handle mail for, add this to the local-host-names file.
Restart sendmail after you make changes to this file.


Linux uses ‘runlevels’ to define the current capability of the system, for example, whether the system is running in single user, multi-user, text or graphical modes.

The default runlevel for when the system boots is defined in the file.

Edit this file and look for a line like this:


- the number specifies the default runlevel.

Valid runlevels are:

  • 0 - Halt the system
  • 1 - Single-user mode
  • 2 - Multi-user mode (without NFS)
  • 3 - Multi-user mode
  • 5 - Multi-user mode, graphical login
  • 6 - Reboot the system

The runlevel can be changed at run time using the init RUNLEVEL where RUNLEVEL is the runlevel you wnat to change to.