Chinaunix首页 | 论坛 | 博客
  • 博客访问: 705083
  • 博文数量: 98
  • 博客积分: 3145
  • 博客等级: 中校
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-15 12:52
文章分类
文章存档

2021年(1)

2020年(1)

2016年(8)

2015年(3)

2014年(1)

2013年(5)

2012年(4)

2011年(9)

2010年(12)

2009年(42)

2008年(12)

我的朋友

分类: LINUX

2008-12-15 13:02:23

安装postfix

#apt-get install postfix postfix-doc postfix-tls postfix-mysql squirrelmail

安装sasl2

#apt-get install libsasl2 libsasl2-modules libsasl2-modules-sql sasl2-bin

#vi /etc/default/saslauthd

 修改

START=yes

 

#/etc/init.d/saslauthd restart

安装mysql

#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;

 安装apache2

#apt-get install apache2 libapache2-mod-php5

安装postfixadmin

#wget 2.2.0.tar.gz

#tar zxvf postfixadmin_2.2.0.tar.gz

#mv postfixadmin-2.2.0 /var/www/mailadmin

#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

 

配置postfix

添加系统需求帐户

#useradd postfix

#useradd maildrop

添加邮件主目录

#mkdir /home/mailbox

#chown –R 33.33 /home/mailbox

 

注:33apache运行帐户

编辑postfix主配置文件

#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'

配置smtpd

#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'

注意:只支持明码认证

重启postfixsasl

#/etc/init.d/postfix reload

#/etc/init.d/saslauthd restart

至此smtpd邮件服务已经安装完毕,可以在客户端,比如outlookfoxmail进行测试了。

安装pop3

安装

#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中的用户密码,和postfixadminconfig.inc.php中的设置一致

阅读(2200) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:MYSQL调优文档1

给主人留下些什么吧!~~