Running Multiple Sendmail Instances on a Debian-like System (Ubuntu 10.4 LTS Server)
When installing Sendmail from the repository packages it is pretty much assumed that you will only be running one instance on a given server. If, like I had to recently, you want to maintain a number of sendmail configurations and process, but want to fit into the Debian rc script scheme, it takes a bit of work.
I’ve created a patch that can be run against the stock /etc/init.d/sendmail script to produce scripts like /etc/init.d/sendmail.mail1 to manage named instances of sendmail. There are a few things you need to know:
- The patched scripts expects to find the configuration for the named instances in /etc/mail/servers/instancename
- The script expects to be called sendmail.instancename
- Along with changing the INSTANCE= variable at the top of the script, be sure to change the comments so that the update-rc.d style daemon registration works if required. A global search and replace is probably your best bet.
- /etc/default/sendmail can be copied to /etc/default/sendmail.instancename and populated, if present or required.
- PID and lock files end up in /var/run/sendmail.instancename. You will need to edit your named instances sendmail.mc/cf to have the PID files created in the correct location. Spools end up in /var/spool/mqueue.instancename
The final piece of configuration required to make this mechanism work is to copy /etc/mail/sendmail.conf to /etc/mail/servers/instancename/sendmail.conf and to modify the MISC_PARMS variable:
MISC_PARMS="-C/etc/mail/servers/INSTANCENAME/sendmail.cf"
Substituting INSTANCENAME as required. This ensures that the correct configuration file is read from.
If you are binding your sendmail instances to different interfaces you might like to also modify the DAEMON_NETIF variable to have the instance watch the correct interface for state changes, if you have DAEMON_NETMODE set to something other than the default “Static”.
Apart from that the patched script does everything that you would expect and the various logged messages reflect the instance name. Managing individual instances then becomes a matter of:
$ sudo service sendmail.mail3 stop $ sudo service sendmail.mail2 start
Easy as that.
www.dailyunixtip.com
Over these last few weeks I’ve finally got it together to dust off the code for www.dailyunixtip.com and get the thing live.
It’s not big and it certainly isn’t that clever, I hope the site is something useful to put on a Google homepage or as a feed in your browser, and that it’ll occasionally turn up the odd little gem.
I would very much appreciate your questions and comments. Please, take a look around the site and if you feel so inclined, sign up and contribute a tip.

