Editing the m4 Configuration File

Sendmail on your system probably has a pretty good feature set included in the default sendmail.cf. But as has been discussed, some features are often left out, such as genericstable. Usually, these features are not needed, but if they are, you must add them to your configuration file. Manually editing the sendmail.cf is generally regarded as not being an option for mere mortals like you and I (Eric Allman, the creator of Sendmail might be able to do it). However, recent versions of Sendmail provide a novel method of adding features to the sendmail.cf which uses a macro file and the m4 macro processor.

Adding a Feature

Unlike directly editing the .cf, adding a feature using the m4 macro file is actually pretty easy. The method used by many sites is discussed here.

First, copy your /etc/sendmail.mc file to a new file. Usually, an administrator will name it after their hostname. So I would call mine /etc/delilah.mc.

# cd /etc
# cp sendmail.mc delilah.mc

Next, open the new file in your favorite text editor. I use vi.

# vi delilah.mc

Finally, you’ll see a file that looks something like this (or almost exactly like this if your system is a Red Hat Linux based system):

dnl This is the macro config file used to generate the /etc/sendmail.cf
dnl file. If you modify the file you will have to regenerate the
dnl /etc/sendmail.cf by running this macro config through the m4
dnl preprocessor:
dnl        m4 /etc/sendmail.mc > /etc/sendmail.cf
dnl You will need to have the sendmail-cf package installed for this to
dnl work.
define(`confTO_CONNECT', `1m')
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not have 24x7 DNS do need this.
dnl FEATURE(`relay_based_on_MX')

Each line, with the exception of the dnl comment lines and the divert(-1) line, are of the form macro-type(value list). In our example, we’re going to add a new feature called genericstable. So we insert a line like this into the FEATURE list:

FEATURE(`genericstable',`hash -o /etc/mail/genericstable')

After saving the changed file, we will generate the new sendmail.cf (don’t forget to backup the old one to another file if you’ve already set up your Sendmail). To create a new sendmail.cf based on your .mc file, you issue the following command:

# m4 /usr/lib/sendmail-cf/m4/cf.m4 delilah.mc > sendmail.cf

Your cf.m4 macro definition file may be in another location, if you do not use Red Hat Linux. It’s usually easy to locate this file however (it often resides somewhere in /usr/lib/sendmail-cf or /usr/share/sendmail.cf). Next we have to create a blank file for the genericstable mappings to be stored in (otherwise Webmin will complain that your configuration is wrong), and set the permissions to something Sendmail will be happy with.

# touch /etc/mail/genericstable
# chmod 644 /etc/mail/genericstable

Once you have added entries to the map table, Webmin will automatically generate the .db map file that Sendmail relies of for these entries, so no other effort on our part is required. Now you should be able to edit the Outgoing Addresses mappings with Webmin, and a restart of Sendmail will put them into effect.

What Linux Junkies Say
Our Blog


Follow Us