configure postfix for mysql based virtual host
- create vmail user
- postfix initial configuration
- postfix virtual_alias_maps
- postfix mysql based main.cf
- creating mysql user account
- postfix mysql database
- postfix mysql_virtual_mailbox_maps.cf
- secure postfix configuration files
- postfix testing mail
- postfix basic spam control
- postfix rbl spam blocking
- postfix transport
- catch all mail box in postfix mail server
Create the file mysql_virtual_mailbox_limit_maps.cf and add the following to it. Remember to adjust the username and password of the database accordingly.
hosts = localhost dbname = email user = username password = password table = mailbox select_field = quota where_field = username
Create the file mysql_relay_domains_maps.cf and add the following to it. Remember to adjust the username and password of the database accordingly.
hosts = localhost dbname = email user = username password = password table = domain select_field = domain where_field = domain
I suggest Courier-imap (mainly cause I can tell you how to configure it). To configure Courier-imap for the Mysql based virtual mail you need to edit the etc/imapd file and create/edit the authmysqlrc file for Courier-imap.
First edit the etc/imapd file and add the following line:
IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE"
Remember to keep it all on one line even if your browser shows it on multiple lines.
Next edit or create the authmysqlrc file (usually found in /etc/authlib after installing courier). Add the following information to the file and remember to adjust the username and password accordingly.
MYSQL_DATABASE email MYSQL_USERNAME username MYSQL_LOGIN_FIELD username MYSQL_CRYPT_PWFIELD password MYSQL_GID_FIELD '89' MYSQL_HOME_FIELD '/usr/local/virtual' MYSQL_MAILDIR_FIELD maildir MYSQL_OPT 0 MYSQL_PASSWORD password MYSQL_QUOTA_FIELD quota MYSQL_SERVER localhost MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_UID_FIELD '89' MYSQL_USER_TABLE mailbox MYSQL_WHERE_CLAUSE `lock`='n'
the uid and gid should be the uid and gid of the postfix user and group.
smtpd.conf file The smtpd.conf file is for AUTH SMTP support. You will need to have it contain the following instead of the default. The file can usually be found in /usr/lib/sasl2.
pwcheck_method: saslauthd mech_list: login plain
saslauthd configuration changes You will need to tell saslauthd to use mechanism rimap instead of shadow to validate using the imap server.
On rpm based distributions you can create/edit the file /etc/sysconfig/saslauthd and put the following lines in it:
MECH="rimap" FLAGS="-O localhost"
If your not using an rpm based distribution you will need to make sure saslauthd is started with saslauthd -a rimap -O localhost. Finishing Up Now restart courier-authlib, courier-imap, saslauthd, and postfix for the virtual mail system. Difference from a regular install (according to the INSTALL file) The hhvacation program should not be installed into /usr/bin on a Postfix/Mysql virtual mail system.
First create a user for vacation with
useradd -d /home/vacation -s /bin/nologin -c "Vacation Responder" vacation
Install the hhvacation file into /home/vacation and make sure it is owned by user vacation.
You will need to edit the hhvacation file and define the following variables.
$virtual="0"; #set this to 1 for virtual mail system $pfhost=""; #set this to the postfix virtual mail db hostname $pfname=""; #set this to the postfix virtual mail db name $pfuser=""; #set this to the postfix virtual mail db username $pfpass=""; #set this to the postfix virutal mail db password
Save the changes and the vacation system is ready to go. The rest of the gnuhh-hhelper package installs just like any other system.
Virtual Mail is not currently supported by the dedicated mail server daemon. Virtual Mail can only be used when mail is hosted on the same server as the web hosting.