How to – Postfix MySQL
Configuration details:-
+ CentOS 5
+ MySQL 5
+ Postfix 2.5
1. Download the latest Postfix from http://www.postfix.org/download.html
2. Untar the file run make command. Do as the following:-
# make install
3. Now to configure Postfix to lookup for aliases in MySQL database
Search the following line and change value to:
4. Now create a new file named mysql-aliases.cf in default Postfix configuration directory. Usually in /etc/postfix
Add the followings:
# The user name and password to log into the mysql server.
user = <database username>
password = <database user password>
# The database name on the servers.
dbname = <database name>
# For Postfix 2.2 and later The SQL query template.
query = SELECT forw_addr FROM mxaliases WHERE alias=”%s”;
5. Restart your postfix
# postfix start
Optional : You can also configure your Postfix to lookup for local recipients using MySQL database. Below is the example for database lookup and configuration with DBMail
6. Create a new file named sql-recipients.cf in Postfix configuration directory
Add the following:
password = <password>
hosts = <dbhost>
dbname = <dbname>
query = SELECT alias FROM dbmail_aliases WHERE alias=’%s’
UNION SELECT userid FROM dbmail_users WHERE userid=’%s’;
7. Configure your main.cf to map to the sql-recipients.cf file:
Look for local_recipient_maps and add the following value:
8. Restart your postfix
# postfix start
Reference Site:
DBMail with Postfix : http://www.dbmail.org/dokuwiki/doku.php?id=setup_postfix
Postfix MySQL : http://www.postfix.org/MYSQL_README.html

Leave a Reply