How to Remove a Host from Sendmail's Class w

Weldon Whipple <>


Sendmail's class w ($=w) is the set of all hosts and IP addresses (etc.) for which sendmail will accept and (attempt to) deliver mail locally.

You can see the contents of your sendmail's class w by issuing this command on your server as root:

# echo '$=w' | sendmail -bt

You will probably become aware of the need to remove an entry from class w if your MX server (for example) is, but you are logged onto and want to send e-mail to Instead of going to, the local server will attempt to deliver it to fred's local mailbox (which may or not exist on

There are several ways that hosts/domains are added to class w. Here are some of the ways:

Ways to Remove an Entry from Class w

Change the File

Try the following, if they apply:

  1. Remove entries from /etc/mail/local-host-names
  2. Remove the host/domain name from a LOCAL_DOMAIN entry in the mc file, then regenerate your
  3. Tell sendmail not to probe interfaces with by inserting the following line in your mc file:
    define(`confDONT_PROBE_INTERFACES', `true')dnl

Rename Your Server

If the host name you want to remove happens to be the hostname of your server, it is probably easiest to rename your server. (This will remove the name from class w, as well as add the server's new name to class w).

If I want to remove from class w, I could rename the server to,,, for example.

Add a Custom LOCAL_RULE_0 to the Sendmail Macro Configuration File

Use this as a last resort. (It actually involves modifying the file, but I didn't include it above because it is the least desirable solution! Also, unless you are very careful, you can break your sendmail configuration)

The example below illustrates a situation where the mail server for the domain is named DNS MX record points to This solution fixes the condition where other hosts on the Net send mail to correctly, but mail originating from the host named, destined for, is unable to leave the server.

If your mc file doesn't already have a LOCAL_RULESETS section, add one. If it does, just add the LOCAL_RULE_0 line--and the line following it--to the existing LOCAL_RULESETS section:

R$* < > $*  <tab>$#esmtp $@ $: $1<>$2
The LOCAL_RULESETS section generally goes last in the sendmail mc file.

Be sure to replace <tab> with an actual tab character! (Press the tab key in your editor.)

After modifying the mc file, generate a new file (making a backup of your original in case your new one doesn't work). Then restart sendmail. Finally, send a few e-mails to make sure sendmail works as expected.


This document is a work in progress. Please send corrections, suggestions and additions to me.