SENDMAIL STUFF
virtusertable
local-host-names
acces.db
Sendmail Version
sendmail.cf and M4

Adding virtual maps AKA: mapping an email address to an account and crap.
This seems to work in Red Hat 9.
Edit the virtual user table located at /etc/mail/virtusertable buy typing:

pico -w /etc/mail/virtusertable

Add the virtual host addresses on the left and the real accounts or forward accounts on the right. To have a catch all for a domain add @domain.com on the left and the account that will get it on the right. Example:

swamp@lickmymammasskull.net      swamp
devo@dogsarestinky.com           user4
@gir_rocks.com                   user_gir
forwardme@gir_rocks.com          crap4me@forwarded.net


Then save the file by hitting ctrl-o and exit pico by hitting ctrl-x.

Now you have to rebuild the virtual user table so your changes will take effect. Use the following command:

makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable


The following example are from Chris Szilagyi's home page.

Here are some more examples of entries to give you an idea of how flexible you can make your server:

These lines:

chris@localdomain.com       chris
jake@localdomain.com        chris


would cause all incoming mail addressed to chris@localdomain.com and jake@localdomain.com to go to the user chris. This allows you to create aliases for each user on your server.

This line:

george@localdomain.com     gsmith@anotherdomain.com

would cause all incoming mail addressed to george@localdomain.com to automatically forward to gsmith@anotherdomain.com. Note, this does not require any local user to be set up.

This line:

bob@localdomain.com         bobsmaillist

would be used if you had several recipients that you wanted mail addressed to bob@localdomain.com to go to. In addition to the entry in the virtusertable file, you will also need to add an entry in /etc/aliases so the server will know who bobsmaillist goes to. An entry like this would work:

bobsmaillist                       bob,asmith@anotherdomain.com

This would deliver the messages to the local user bob and also forward to asmith@anotherdomain.com. Remember to do a "newaliases" after you modify the /etc/aliases file!

You can also accept mail for an entire domain, and do whatever you want with that also:

@domain1.com                    jim

which would deliver any message to the domain domain1.com to the local user jim. This means if somebody sent a message to webmaster@domain1.com, somebody@domain1.com, or anything @domain1.com, it would be delivered to jim.
And, there's one more neat little forwarding entry you can use:

@domain1.com                   %1@anotherdomain.com

This would forward anything coming in to an address at domain1.com and forward to the same thing at anotherdomain.com. For instance, if a message came in to webmaster@domain1.com, it would forward the message to webmaster@anotherdomain.com.

And, at last, you will need to enter what we call catch-all keys to the virtusertable file. Catch-all keys are entries that you need to add so that if an incoming message doesn't fit any of the entries in your virtusertable file, an error message will be sent back to the sender. This also will prevent messages that are sent to an address that doesn't exist getting delivered to the wrong person. For instance (and I'll try not to let this get too confusing), let's say you had the following accounts set up on your server:
jim@localdomain.com that goes to the local user james.

If somebody was to send a message to james@localdomain.com and there wasn't an entry in your virtusertable of james@localdomain.com, the message would be delivered to the local user james. Sendmail tries to deliver to the local user if it can't find an entry in the virtusertable. So, for each domain you are accepting mail for, you will want to add a catch-all key like this:

@localdomain.com              error:nouser User unknown

So, now if somebody was to send a message to james@localdomain.com, and there wasn't an entry in your virtusertable for james@localdomain.com, an error message would be send back to the sender with an User unknown error. Note: you can change the actual error cause to anything you wish by simply putting what you want in after error:nouser. So, if you used error:nouser No such user here, the sender would have received a return message with the error of "No such user here".


local-host-names
This seems to work in Red Hat 9.
The local-host-names file is just that, a list of your local host names. Edit the /etc/mail/local-host-names file with you favorite editor (pico or what not) and then rebuild it by typing:
makemap hash /etc/mail/local-host-names < /etc/mail/local-host-names

Flush specific messages from sendmail queue
I just found out about this feature for flushing the sendmail queue. This is useful if, say, your mail server was down all weekend and you JUST CAN'T WAIT for the normal queue flush to occur because you've gone through email withdrawl by not being connected for a couple days. In the event that you, say, just rebuilt your mail server and wanted to make sure everything was working correctly you'd also want to watch the queue as it's processing. Normally you'd just run the following to flush the queue and see the results:
# /usr/sbin/sendmail -q -v

This is fine, but you wind up hanging on those other lame entries in the queue there because the mail server is offline, doesn't exist, didn't have its coffee, etc. The timeouts on these things will kill you and you never know where they'll appear during your flush. This means no immediate gratification, which was the whole point of the exercise. Instead you can tell sendmail to only flush certain items from the queue with an additional argument to -q. So you can do:

# /usr/sbin/sendmail -qR cwinters.com -v

To only process entries in the queue with a recipient having 'cwinters.com' in it. Sweet! You can also use -qS to match on the sender and -qI to match on the queue ID.


The Access Database (access.db)

The access database (normally in /etc/mail/access) allows a mail administrator to administratively allow access to the mail server by individual domains. Each database entry consists of a domain name or network number as the key and an action as the value.

Keys can be a fully or partly qualified host or domain name such as host.subdomain.domain.com, subdomain.domain.com, or domain.com. The last two forms match any host or subdomain under the specified domain. (If FEATURE(relay_hosts_only) is set, only the first form works.) Keys can also be a network address or subnetwork, e.g., 205.199.2.250, 205.199.2, or 205.199. The latter two forms match any host in the indicated subnetwork. Lastly, keys can be user@host.domain to reject mail from a specific user.

Values can be REJECT to refuse connections from this host, DISCARD to accept the message but silently discard it (the sender will think it has been accepted), OK to allow access (overriding other built-in checks), RELAY to allow access including relaying SMTP through your machine, or an arbitrary message to reject the mail with the customized message.

For example, a database might contain:

cyberpromo.com    REJECT
sendmail.org      RELAY
spam@buyme.com    550 Spammers shan't see sunlight here


to reject all mail from any host in the cyberpromo.com domain, allow any relaying to or from any host in the sendmail.org domain, and reject mail from spam@buyme.com with a specific message.

Note that the access database is a map and just as with all maps, the database must be generated using makemap. For example:

makemap hash /etc/mail/access < /etc/mail/access
Sendmail Version
To see your installed sendmail version:
sendmail -d0 < /dev/null | grep -i version
These options display useful version and configuration information.
sendmail -d0.1 -bt < /dev/null
sendmail.cf & M4
The default sendmail.cf file does not allow Sendmail to accept network connections from any host other than the local computer. To configure Sendmail as a server for other clients, edit /etc/mail/sendmail.mc and change DAEMON_OPTIONS to also listen on network devices or comment out this option all together. Then regenerate /etc/mail/sendmail.cf by running:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf