Normally, when you send emails out from your sendmail server, the messages are sent using the primary IP address of your default interface controller (also referenced by But what happens if you have a multi-homed system, for example with multiple IP addresses assigned to a single physical interface, and you want all outbound emails to be sent from one of your virtual addresses rather than your primary address? Well, the truth is, making this change (and just about any change in sendmail) is actually pretty easy once you know what you're doing.

The sendmail configuration files can normally be found in /etc/mail, and are of the type *.cf. These files contain various complex lines to control sendmail, and at first glance may been pretty intimidating, but luckily there is a good solution to managing them that does not require editing them by hand.

Sendmail's configurations are controlled by a macroprossessor (in this case m4). The idea is that you can edit a few simple lines in the macroprossessor control file (*.mc) and allow the macroprossessor to compile and build your sendmail control files for you!

So to accomplish this task, for example, you would open your file and insert the following line:

CLIENT_OPTIONS(`Family=inet, Address=x.x.x.x')

You can replace x.x.x.x with whatever IP address you would like, and then run make to launch the m4 compilation for you (and yes, that is a back-tick before Family, not an apostrophe).

make -C /etc/mail

Once finished, you should just be able to restart your sendmail service and viola! Your outbound emails should now be sent from the new IP. (Of course this IP needs to be one assigned to your machine in order to work).

service sendmail restart

In real-world situations though, things can become a little more complicated (especially if you are inheriting admin responsibilities for a system you did not setup). For example, on a freebsd 8 server I was managing once, there were 3 control files (,, and and only one macroprossessor file ( So which files do you need to edit? Well, truth be told, the file is probably going to be the only file that makes a difference here, and on my systems there wasn't even a file.

On the one hand, I could have created a file, made the changes I needed, run make and then have my new control file generated for me. In the heat of battle however, I found it much easier to just edit the file directly and worry about creating the macroprossessor file later. In the control file, I simply looked for the line:

#O ClientPortOptions=Family=inet, Address=

Uncommented it, and replaced the address with the one I needed. Then restarted sendmail and was working quite the same way as if I had used the macroprossessor to build it for me (however, editing the file directly is not recommended as it is prone to more error).