Postfix + mysql
[1.] 抓取tarball,重新編譯postfix
make -f Makefile.init Makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm' ; make ; make install
當make install時,只要一直按enter就行(使用預設值),如此它會更新postfix。
[2.] postconf -m
btree
cidr
environ
hash
mysql
nis
pcre
proxy
regexp
static
unix
[3.] vi /etc/postfix/main.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
[4.] vi /etc/postfix/mysql_virtual_mailbox_maps.cf
#
# mysql config file for local(8) aliases(5) lookups
#user = postfix
password = postfix
hosts = localhost
dbname = postfix# postfix 2.2版本以下的設定
table = mailbox
select_field = maildir
where_field = username
additional_conditions = and active = '1'# postfix 2.2版本以上的設定
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
[5.] 設定 MySQL
mysql> CREATE DATABASE postfix;
mysql> GRANT ALL ON postfix.* TO 'postfix'@'localhost' IDENTIFIED BY 'postfix';
mysql> USE postfix;
CREATE TABLE `mailbox` (
`username` varchar(255) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`maildir` varchar(255) NOT NULL default '',
`quota` int(10) NOT NULL default '0',
`domain` varchar(255) NOT NULL default '',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
`active` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`username`)
) TYPE=MyISAM COMMENT='Postfix Admin – Virtual Mailboxes';
mysql> INSERT INTO mailbox (username,password,name,maildir) VALUES ('[email protected]','$1$caea3837$gPafod/Do/8Jj5M9HehhM.','Mailbox User','[email protected]/');
註: password是MD5加密 = secret
ref: http://www.postfix.org/MYSQL_README.html
http://postfixwiki.org/index.php?title=Virtual_Users_and_Domains_with_Courier-IMAP_and_MySQL#Create_the_database
留言