Extras/PostfixWithMySQL

= Postfix With My SQL =

Making Postfix work with MySQL
Unfortunately, since many people choose not to install Postfix, MySQL support is not turned on, by default, in the Postfix binary RPM. Turning it on would add some MySQL packages to the list of prerequisites for Postfix, and, frankly, if you are not going to use them, you do not need them. 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.

I am writing this because I could not find any instructions for doing this. The standard scheme is, according to the Postfix documentstion, to create separate postfix-mysql, postfix-ldap, and so forth RPM packages that are installed to add the capability. I went looking for these packages, but was not able to find them for Fedora, despite implications that they should exist. I spent some time with packages for other sources before I gave up, and decided to grab the source and look in it for answers. Once I did that, the answer was apparrent quickly, but it took so long to get there that I decided to write this guide to help others.

Follow these steps
1. Get the Fedora source RPM for the level of Postfix you want to install. rpm -Uvh /tmp/postfix-2.0.16-1.src.rpm Where that happens to be the path to and name of the source RPM I grabbed, from testing. You should install whatever level you choose. %define MYSQL 0 Find that line, and change the 0 to a 1. Save the file. rpmbuild -bb /usr/src/redhat/SPECS/postfix.spec You should see the files go by, and you should see compiler options mentioning MySQL and libraries. rpm -uvh /usr/src/redhat/RPMS/i386/postfix-2.0.16-1.i386.rpm
 * Install the source RPM. This is a simple matter of running:
 * By default, the source is installed in /usr/src/redhat/. The actual source will go into /usr/src/redhat/SOURCES and the specfile will go in /usr/src/redhat/SPECS. Make sure you can find them.
 * Edit the file /usr/src/redhat/SPECS/postfix.spec. Near the beginning, there is a line that says
 * Use buildrpm to build a new binary RPM, by using the command
 * The RPM that was built will be deposited in /usr/src/redhat/$arch/. In my case, the RPM is called /usr/src/redhat/RPMS/i386/postfix-2.0.16-1.i386.rpm. Find the binary RPM.
 * Install the binary RPM with a command such as
 * Do cleanup as appropriate.

Optional Steps
If you have already installed this level of postfix, the rpm command will balk at installing the same level of the postfix package over again. To increment the subrelease number, you must edit the spec file, and change the line that says: Release: 1 to Release: 2 In my case, the original release was 1, and I wanted to change it to 2, so as to make the install work. I could have used --force once I was sure that everything was right, but, frankly, I wanted to make it work as it was designed. The risk is that someone will create an official Release 2 of the same level of postscript --- but since I am faced with installing postfix from source RPMs in all cases in any case, I will want to do something to save myself from having the Postfix rpm overlaid. To make it clear, however, 1 and 2 are examples --- you might have a different starter number, just increase it.

Finally, you are now in the situation where, as and if new releases of Postfix come out, you will not want to automatically install them. How you stop new versions of a package from installing is up to you - there is a simple way to do it with up2date --configure. With yum, editing the /etc/yum.conf file and adding postfix to the exclude line will do it.

Once you have done the installation, you can verify it, simply, by running the command postconf -m. This lists the types of tables that Postfix can use, and you ahould be able to see the fact that mysql is now a supported table type.

How to use mysql tables in postfix is covered in several howto's, of which there are many listed at  with one of the best being at.

I tried to follow your steps since the web-cyradm requires either Postgress or MySQL for authentication. Unfortunately I couldn't get it to work with the latest SRPM. It failed stating a man page. I ended up using the latest SRPM from here, but that causes some dependency problems with sasl. Using --force I was able to install it. Man it would be nice of postfix-mysql was part of the Fedora tree. Either that or have postfix load its authentication modules dynamically like PAM, so the authentication modules could be packaged separately from the server.

christopher baus

Instead of building Postfix as root, it should be built as a non root user.

create a file called /.rpmmacros containing the following: %_topdir               %(/bin/echo $HOME)/rpm %_tmppath              %{_topdir}/tmp Then created the following directory structure in your home directory: mkdir -p /rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp} mkdir -p /rpm/RPMS/{i386,i486,i586,i686,athlon,noarch} Then you can install the src.rpm as your normal user in the manner described above, edit the spec file to turn on MySQL support (spec file will be in /rpm/SPECS/) and build it as your normal user.