Switching To Postfix
Special instructions for Switching to Postfix from Sendmail in Fedora
Fedora comes with RPMs for both Sendmail and Postfix. The default configuration is to use Sendmail in a mode where your system does not listen to any other system. This setup is fine for simple usage, such as sending locally initiated cron job output to a different system. Many users, myself included, prefer Postfix as a Mail Transfer Agent (MTA) when a system is accepting mail, especially when they have a complex system that supports multiple virtual systems, more than one list manager, address munging and filtration, and the like. There is reference to Postfix in the release notes that come with Fedora, but for someone like me who is running self-installed Postfix on Redhat 5 and 7.x, it was not initially apparent how to select one mail program or another.
Why are there special instructions? The two packages use the same names for some binaries, and they use the same resources (they both listen on port 25, for example). Postfix provides a binary named sendmail that does some of the things that the sendmail binary in the sendmail package does. There needs to be some special method to switch between these binaries. One of the limitations of the RPM system is that a file may only be owned by one package. An artifact of this scheme is that no package owns the file /usr/sbin/sendmail, although, arguably, it could be owned by the package system-switch-mail or perhaps the chkconfig package, which owns /usr/sbin/alternatives.
Historically, the best way to install postfix on Redhat was to get a copy of the source, apply the right patches to it, and to simply erase some of the sendmail binaries and install the postfix source without removing the sendmail RPM. Some people had prepared Postfix RPMs, but they did not wortk and play well with the base system, and, in many cases, you wanted options that were not supported in the RPMs. Some of the packages you might install formally required a sendmail function, so you could not remove the sendmail package. This interacted badly with regular maintenance - as installing errata could replace pieces of postfix, but not all of it, of course.
Even if I were going to install Postfix from non-RPM source (and, of course, lose all support), I would follow the procedure below to establish the ownership of the files and to get them under the postfix umbrella.
The below procedure will not be covered in the Postfix documentation, and it is not covered in the Fedora Release notes. I was told that it was in an earlier release's notes. I was unable to find it.
Step 1: Install Postfix
If rpm -q postfix responds with postfix-2.0.11-5 or higher, then you have postfix installed. If not, use your favorite install scheme to install postfix from a mirror of the Fedora repository. Some possibilities are:
- yum install postfix
- up2date postfix
- apt-get install postfix
The postfix RPM that was prepared by Fedora is essential for this, as it works and plays well with the next step. It is also possible to grab the RPM from the install media or a repository, and to then install it with rpm -Uvh postfix* where you name the actual postfix rpm file on the command line.
Step 2: Switch to your preferred MTA - in this example, from sendmail to postfix:
/usr/sbin/system-switch-mail or /usr/sbin/system-switch-mail-nox
If you do not have these commands, then it is likely that, the system-switch-mail package was not installed. Install this package from a mirror of the Fedora repository or your install CDs.
- yum install system-switch-mail
- up2date system-switch-mail
- apt-get install system-switch-mail
When you run the system-switch-mail[-nox] command, you will see a self-explanatory selection dialog. Examination of the source shows that the dialog allows you to switch between postfix, sendmail and exim, if installed. You will only be allowed to select an MTA that you have installed.
Step 3: Verify that the correct daemon will be started
To verify that the switching script has run correctly, you may want to insure that the MTA process is starting. Run /usr/bin/system-config-services if you have X available, and insure that postfix will be started in the runlevel you care about when the system restarts. Sendmail should no longer appear in the list that you see. If you do not have X, use chkconfig --list postfix and chkconfig --list sendmail. You should only see entries for the MTA that you have switched to. For other MTAs, you should get a message of the form: service sendmail supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add sendmail').
Finally, you might want to use MySQL with Postfix. Unfortunately, since many people choose not to install Postfix, MySQL support is not turned on, by default, in the Postfix binary RPM. The good news is that the Source RPM Specfile has done all of the hard work, and it is a simple matter to rebuild it. You can find out how in PostfixWithMySQL .