Virtual Users And Domains With Postfix, Courier And MySQL (Fedora Core 5) - Page 2
6 Create The MySQL Database For Postfix/CourierWe create a database called mail: mysqladmin -u root -p create mail Next, we go to the MySQL shell: mysql -u root -p On the MySQL shell, we create the user mail_admin with the passwort mail_admin_password (replace it with your own password) who has SELECT,INSERT,UPDATE,DELETE privileges on the mail database. This user will be used by Postfix and Courier to connect to the mail database: GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail_admin'@'localhost' IDENTIFIED BY 'mail_admin_password'; Still on the MySQL shell, we create the tables that Postfix and Courier need: USE mail; CREATE TABLE domains ( CREATE TABLE forwardings ( CREATE TABLE users ( CREATE TABLE transport ( quit; As you may have noticed, with the quit; command we have left the MySQL shell and are back on the Linux shell. The domains table will store each virtual domain that Postfix should receive emails for (e.g. example.com).
The forwardings table is for aliasing one email address to another, e.g. forward emails for info@example.com to sales@example.com.
The users table stores all virtual users (i.e. email addresses, because theemail address and user name is the same) and passwords (in encrypted form!) and a quota value for each mail box (in this example the default value is 10485760 bytes which means 10MB).
The transport table is optional, it is for advanced users. It allows to forward mails for single users, whole domains or all mails to another server. For example,
would forward all emails for example.com via the smtp protocol to the server with the IP address 1.2.3.4 (the square brackets [] mean "do not make a lookup of the MX DNS record" (which makes sense for IP addresses...). If you use a fully qualified domain name (FQDN) instead you would not use the square brackets.).
7 Configure PostfixNow we have to tell Postfix where it can find all the information in the database. Therefore we have to create six text files. You will notice that I tell Postfix to connect to MySQL on the IP address 127.0.0.1 instead of localhost. This is because Postfix is running in a chroot jail and does not have access to the MySQL socket which it would try to connect if I told Postfix to use localhost. If I use 127.0.0.1 Postfix uses TCP networking to connect to MySQL which is no problem even in a chroot jail (the alternative would be to move the MySQL socket into the chroot jail which causes some other problems). Now let's create our six text files. vi /etc/postfix/mysql-virtual_domains.cf
vi /etc/postfix/mysql-virtual_forwardings.cf
vi /etc/postfix/mysql-virtual_mailboxes.cf
vi /etc/postfix/mysql-virtual_email2email.cf
vi /etc/postfix/mysql-virtual_transports.cf
vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
(If you compare these files with the files from http://www.howtoforge.com/virtual_postfix_mysql_quota_courier, you will notice that the format is different. This is because the syntax changed from Postfix 2.1 to 2.2. In this tutorial we use Postfix 2.2.8, in the other one it's 2.1.5.) chmod o= /etc/postfix/mysql-virtual_*.cf Now we create a user and group called vmail with the home directory /home/vmail. This is where all mail boxes will be stored. groupadd -g 5000 vmail Next we do some Postfix configuration. Go sure that you replace server1.example.com with a valid FQDN, otherwise your Postfix might not work properly! postconf -e 'myhostname = server1.example.com' Afterwards we create the SSL certificate that is needed for TLS: cd /etc/postfix <-- Enter your Country Name (e.g., "DE"). Then change the permissions of the smtpd.key: chmod o= /etc/postfix/smtpd.key
8 Configure SaslauthdEdit /usr/lib/sasl2/smtpd.conf. It should look like this: vi /usr/lib/sasl2/smtpd.conf
Then turn off Sendmail and start Postfix, saslauthd, and courier-authlib: chmod 755 /var/spool/authdaemon chkconfig --levels 235 sendmail off
9 Configure CourierNow we have to tell Courier that it should authenticate against our MySQL database. First, edit /etc/authlib/authdaemonrc and change the value of authmodulelist so that it reads vi /etc/authlib/authdaemonrc
Then edit /etc/authlib/authmysqlrc. It should look exactly like this (again, make sure to fill in the correct database details): vi /etc/authlib/authmysqlrc
Then restart Courier: chkconfig --levels 235 courier-imap on By running telnet localhost pop3 you can see if your POP3 server is working correctly. It should give back +OK Hello there. (Type quit to get back to the Linux shell.)
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com




![Creative Commons Attribution-NonCommercial-ShareAlike 2.0 License [Creative Commons Attribution-NonCommercial-ShareAlike 2.0 License]](http://creativecommons.org/images/public/somerights20.gif)

print: 
Recent comments
20 hours 12 min ago
21 hours 40 min ago
1 day 1 hour ago
1 day 4 hours ago
1 day 7 hours ago
1 day 7 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 10 hours ago