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):

divert(-1)
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
dnl        m4 /etc/sendmail.mc > /etc/sendmail.cf
dnl
dnl You will need to have the sendmail-cf package installed for this to
dnl work.
include(`/usr/lib/sendmail-cf/m4/cf.m4')
define(`confDEF_USER_ID',``8:12'')
OSTYPE(`linux')
undefine(`UUCP_RELAY')
undefine(`BITNET_RELAY')
define(`confAUTO_REBUILD')
define(`confTO_CONNECT', `1m')
define(`confTRY_NULL_MX_LIST',true)
define(`confDONT_PROBE_INTERFACES',true)
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')
FEATURE(`smrsh',`/usr/sbin/smrsh')
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')
FEATURE(redirect)
FEATURE(always_add_domain)
FEATURE(use_cw_file)
FEATURE(local_procmail)
MAILER(procmail)
MAILER(smtp)
FEATURE(`access_db')
FEATURE(`blacklist_recipients')
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.
FEATURE(`accept_unresolvable_domains')
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

Internet Marketing

https://youtu.be/3ShchJohuJ8 What is an internet marketing specialist and what do they do? The definition of an internet marketer. A video from the http://bealwaysmarketing.com team outlining

Read More »

Newsletter

Follow Us