29.4. Changing the Mail Transfer Agent
Prev | Chapter 29. Electronic Mail | Next

## 29.4. Changing the Mail Transfer Agent

Written by Andrew Boothman.
Information taken from emails written byGregory Neil Shapiro.

FreeBSD comes with Sendmail already installed as the MTA which is in charge of outgoing and incoming mail.

However, the system administrator can change the system's MTA. The reasons for doing so range from wanting to try out another MTA to needing a specific feature or package which relies on another MTA. Whatever the reason, FreeBSD makes it easy to make the change.

### 29.4.1. Install a New MTA

A wide choice of MTAs is available from the `mail` category of the FreeBSD Ports Collection.

Once a new MTA is installed, configure the new software and decide if it really fulfills your needs before replacing Sendmail.

Refer to the new chosen MTA's documentation for information on how to configure the software.

### 29.4.2. Disable Sendmail

### Warning:

If Sendmail's outgoing mail service is disabled, it is important that it is replaced with an alternative mail delivery system. Otherwise, system functions such as periodic(8) will be unable to deliver their results by email. Many parts of the system expect a functional MTA. If applications continue to use Sendmail's binaries to try to send email they are disabled, mail could go into an inactive Sendmail queue, and never be delivered.

In order to completely disable Sendmail, including the outgoing mail service, add or edit the following lines in `/etc/rc.conf`:

sendmail_enable="NO" sendmail_submit_enable="NO" sendmail_outbound_enable="NO" sendmail_msp_queue_enable="NO"

To only disable Sendmail's incoming mail service, set

sendmail_enable="NO"

in `/etc/rc.conf`. More information on Sendmail's startup options is available in rc.sendmail(8).

### 29.4.3. Running the New MTA on Boot

The new MTA can be started during boot by adding a configuration line to `/etc/rc.conf`. This example enables the Postfix MTA:

`#` echo '`postfix`_enable=“YES”' >> /etc/rc.conf

The specified MTA will now be automatically started during boot.

### 29.4.4. Replacing Sendmail as the System's Default Mailer

Sendmail is so ubiquitous as standard software on UNIX® systems that some software assumes it is already installed and configured. For this reason, many alternative MTAs provide their own compatible implementations of the Sendmail command-line interface in order to facilitate using them as “drop-in” replacements for Sendmail.

When using an alternative MTA, make sure that software trying to execute standard Sendmail binaries, such as `/usr/bin/sendmail`, actually execute the chosen mailer instead. Fortunately, FreeBSD provides a system called mailwrapper(8) for this purpose.

When Sendmail is operating as installed, `/etc/mail/mailer.conf` will look like this:

sendmail /usr/libexec/sendmail/sendmail send-mail /usr/libexec/sendmail/sendmail mailq /usr/libexec/sendmail/sendmail newaliases /usr/libexec/sendmail/sendmail hoststat /usr/libexec/sendmail/sendmail purgestat /usr/libexec/sendmail/sendmail

When any of the commands listed on the left are run, the system actually executes the associated command shown on the right instead. This system makes it easy to change what binaries are executed when these default `Sendmail` functions are invoked.

As an example, to run `/usr/local/supermailer/bin/sendmail-compat` instead of Sendmail, specify the paths to the installed applications in `/etc/mail/mailer.conf`:

sendmail /usr/local/supermailer/bin/sendmail-compat send-mail /usr/local/supermailer/bin/sendmail-compat mailq /usr/local/supermailer/bin/mailq-compat newaliases /usr/local/supermailer/bin/newaliases-compat hoststat /usr/local/supermailer/bin/hoststat-compat purgestat /usr/local/supermailer/bin/purgestat-compat

### 29.4.5. Finishing

Once everything is configured, either kill the unneeded sendmail processes and start the processes belonging to the new software, or reboot. Rebooting provides the opportunity to ensure that the system is correctly configured to start the new MTA automatically on boot.

Prev | Up | Next
29.3. Sendmail Configuration | Home | 29.5. Troubleshooting

This, and other documents, can be downloaded from http://ftp.FreeBSD.org/pub/FreeBSD/doc/

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.