分类: LINUX
2008-12-15 13:02:23
#apt-get install postfix postfix-doc postfix-tls postfix-mysql squirrelmail
#apt-get install libsasl2 libsasl2-modules libsasl2-modules-sql sasl2-bin
#vi /etc/default/saslauthd
修改
START=yes
#/etc/init.d/saslauthd restart
#apt-get install mysql-server-5.0
#mysql –uroot –p
mysql>create database postfix;
mysql> GRANT ALL PRIVILEGES ON postfix.* TO postfix@"localhost" IDENTIFIED BY 'postfix' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
#apt-get install apache2 libapache2-mod-php5
#wget
#tar zxvf postfixadmin_
#mv postfixadmin-
#cd /var/www/mailadmin
#vi config.inc.php
修改数据库连接
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfix';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';
修改密码编码
$CONF['encrypt'] = 'cleartext';
登陆postfixadmin管理界面
注意:xxx.xxx.xxx.xxx为所在服务器IP地址,或者使用解析的域名
点击setup之后加入管理帐户
比如:账号:test@test.com密码:123456
#cd /var/www/mailadmin/
#mv setup.php setup.php.bak
#vi config.inc.php
修改$CONF['configured']
$CONF['configured'] = ture;
浏览器登陆
就会出现登陆界面:就可以用test@test.com/123456登陆管理了,先添加一个域,再添加一个测试邮件,例如:
域:test.com
邮件:t1@test.com/123456
#useradd postfix
#useradd maildrop
#mkdir /home/mailbox
#chown –R 33.33 /home/mailbox
注:33是apache运行帐户
#cd /etc/postfix
#vi main.cf
内容如下:
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = test.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = test.com localhost.com , localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
#=============sasl2====================#
smtpd_sasl_auth_enable = yes
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain =
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, check_relay_domains, reject_unauth_destination
smtpd_sasl_security_options = noanonymous
smtpd_client_restrictions = permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_sender_domain,reject_unknown_recipient_domain,permit_mynetworks,reject_unauth_destination,reject_rbl_client relays.ordb.org,reject_rbl_client list.dsbl.org,reject_rbl_client sbl.spamhaus.org,reject_rbl_client cbl.abuseat.org,reject_rbl_client dul.dnsbl.sorbs.net,permit
smtpd_data_restrictions =reject_unauth_pipelining,permit
#=================mysql================#
virtual_transport = virtual
virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_mailbox_domains.cf
virtual_mailbox_base = /home/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_mailbox_maps.cf
virtual_minimum_uid = 33
virtual_uid_maps = static:33
virtual_gid_maps = static:33
virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_alias_maps.cf
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost =
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
创建虚拟配置文件:
#mkdir /etc/postfix/mysql
# vi /etc/postfix/mysql/mysql_mailbox_domains.cf
内容:
hosts = 127.0.0.1
user = postfix
password = postfix
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and active='1'
# vi /etc/postfix/mysql/mysql_mailbox_maps.cf
内容:
hosts = 127.0.0.1
user = postfix
password = postfix
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
additional_conditions = and active='1'
# vi /etc/postfix/mysql/mysql_alias_maps.cf
内容:
hosts = 127.0.0.1
user = postfix
password = postfix
dbname = postfix
table = alias
select_field = goto
where_field = address
additional_conditions = and active='1'
#vi /etc/postfix/sasl/smtpd.conf
内容:
pwcheck_method: auxprop
mech_list: plain login digest-md5 cram-md5
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: postfix
sql_passwd: postfix
sql_database: postfix
sql_select: SELECT password FROM mailbox WHERE username='%u@%r' and domain='%r'and active='1'
注意:只支持明码认证
重启postfix和sasl
#/etc/init.d/postfix reload
#/etc/init.d/saslauthd restart
至此smtpd邮件服务已经安装完毕,可以在客户端,比如outlook或foxmail进行测试了。
#apt-get install courier-base courier-pop courier-imap courier-authdaemon courier-authlib-mysql
# vi /etc/courier/authdaemonrc
加入
authmodulelist="authmysql"
#vi /etc/courier/ authmysql
加入
MYSQL_SERVER 127.0.0.1
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_USERNAME postfix
MYSQL_PASSWORD postfix
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
MYSQL_LOGIN_FIELD username
MYSQL_CLEAR_PWFIELD password
#MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD '33'
MYSQL_GID_FIELD '33'
MYSQL_HOME_FIELD '/home/mailbox/'
MYSQL_MAILDIR_FIELD maildir
#MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(username,'@',-1),'/',SUBSTRING_INDEX
(username,'@',1),'/')
MYSQL_NAME_FIELD name
MYSQL_QUOTA_FIELD quota
MYSQL_WHERE_CLAUSE active='1'
重启服务
#/etc/init.d/courier-authdaemon restart
#/etc/init.d/courier-imap restart
#/etc/init.d/courier-pop restart
注意:MYSQL_CLEAR_PWFIELD password 用明文方式去抓mysql中的用户密码,和postfixadmin的config.inc.php中的设置一致