/ 中存储网

extmail+postfix安装配置步骤

2014-12-25 14:47:18 来源:中存储网

   本系统采用目前企业比较普遍的postfix+extmail系统,其中管理采用extman系统,使用环境为apache+mysql,邮件系统认证使用mysql方式,POP3支持用courier软件。全套系统用的开源环境,测试收发邮件及客户端pop3均正常,认证密码采用md5crypt加密。

 硬件准备:

   一台服务器,配置要求能安装debian系统,并且硬盘空间有10G以上(存放mail)

 软件准备:

 操作系统:debian4 update8

WEBMAIL:

 下载extmail/extman

登陆http://www.extmail.org/cgi-bin/download.cgi,下载最新的extmail/extman

下载下面3个文件:

extmail-1[1][1].1.1.tar.gz  extman-1[1][1].0.1.tar.gz  maildir_upgrade_mysql-1[1][1].0.tar.gz

放到/opt/distfiles/下

系统环境:

需要安装下面包:

libperl-dev

rrdtools

libperl-dev

libsendmail-pmilter-perl

libtime-modules-perl

libtime-period-perl

libsys-syslog-perl

libunix-syslog-perl

libgd-securityimage-perl

libgd-perl

librrds-perl

libfile-tail-perl

libart-dev

libart-2.0-dev

libart2

libpng12-dev

libpng12-0

libttf-dev

libttf2

tk8.3 

tk8.3-dev

2.1安装apache2+php+mysql环境

说明:其实php是不用安装的

安装apache2+php5:

#apt-get install apache2 libapache2-mod-php5

注:apache需要配置suexec模块支持

安装mysql:

#apt-get install mysql-server-5.0

注:默认密码为空

2.2安装postfix

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

2.3 安装SASL2

#apt-get install libsasl2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl libpam-modules libpam-mysql

2.4 安装COURIER

#apt-get install courier-base courier-pop courier-imap courier-authdaemon courier-authlib-mysql

3.1配置postfix

加入内容:

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

myhostname = vip.eol.cn

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

myorigin = /etc/mailname

mydestination =

relayhost =

mynetworks = 0.0.0.0/8

inet_interfaces = all

#=====================MySQL=====================

virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf

virtual_uid_maps = static:105

virtual_gid_maps = static:105

virtual_mailbox_base = /home/domains

virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf

virtual_mailbox_limit = 51200000

virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

virtual_minimum_uid = 105

virtual_transport = virtual

#=====================Quota=====================

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf

virtual_mailbox_limit_override = yes

virtual_maildir_limit_message = Sorry, the user‘s maildir has overdrawn his diskspace quota, please try again later.

virtual_overquota_bounce = yes

#=====================SASL2====================

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_delay_reject=yes

smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,permit_auth_destination,reject

smtpd_client_restrictions = permit_sasl_authenticated

创建mysql虚拟配置文件:

#vi /etc/postfix/mysql/mysql_virtual_alias_maps.cf

加入:

user = extmail

password = extmail

#hosts = localhost

hosts = 219.224.99.244

dbname = extmail

table = alias

select_field = goto

where_field = address

additional_conditions = AND active = ‘1‘

#vi /etc/postfix/mysql/mysql_virtual_domains_maps.cf

加入:

user = extmail

password = extmail

#hosts = localhost

hosts = 219.224.99.244

dbname = extmail

table = domain

select_field = domain

where_field = domain

additional_conditions = AND active = ‘1‘

#vi /etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

加入:

user = extmail

password = extmail

#hosts = localhost

hosts = 219.224.99.244

dbname = extmail

table = mailbox

select_field = maildir

where_field = username

additional_conditions = AND active = ‘1‘

#vi /etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf

加入:

user = extmail

password = extmail

#hosts = localhost

hosts = 219.224.99.244

dbname = extmail

table = mailbox

select_field = quota

where_field = username

additional_conditions = AND active = ‘1‘

3.2配置smtp

#vi /etc/default/saslauthd

将start=no改成yes

#vi /etc/postfix/sasl/smtpd.conf

加入:

pwcheck_method: authdaemond

log_level: 7

mech_list: plain login

authdaemond_path:/var/run/courier/authdaemon/socket

加入:

auth    required  pam_mysql.so user=extmail passwd=extmail host=202.205.109.7 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1

account sufficient pam_mysql.so user=extmail passwd=extmail host=202.205.109.7 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1

3.3配置pop3

修改下面一些地方:

POP3AUTH="" 改为POP3AUTH=" CRAM-MD5"

#mv /etc/courier/authdaemonrc /etc/courier/authdaemonrc.bak

#vi /etc/courier/authdaemonrc

加入:

authmodulelist="authmysql"

authmodulelistorig="authmysql"

version="authdaemond.mysql"

daemons=5

subsystem=mail

DEBUG_LOGIN=2

DEFAULTOPTIONS=""

authdaemonvar=/var/run/courier/authdaemon

#vi /etc/courier/authmodulelist

修改认证模式为authmysql

# mv /etc/courier/authmysqlrc /etc/courier/authmysqlrc.bak

#vi /etc/courier/authmysqlrc

加入:

MYSQL_SERVER    219.224.99.244

MYSQL_PORT 3306

MYSQL_USERNAME   extmail

MYSQL_PASSWORD   extmail

MYSQL_SOCKET   /var/run/mysqld/mysqld.sock

MYSQL_DATABASE   extmail

MYSQL_USER_TABLE   mailbox

MYSQL_CRYPT_PWFIELD     password

MYSQL_UID_FIELD         uidnumber

MYSQL_GID_FIELD         gidnumber

MYSQL_LOGIN_FIELD       username

MYSQL_HOME_FIELD        homedir

MYSQL_NAME_FIELD        name

MYSQL_MAILDIR_FIELD     maildir

MYSQL_QUOTA_FIELD       quota

MYSQL_SELECT_CLAUSE     SELECT username,password,"",uidnumber,gidnumber,

CONCAT(‘/home/domains/‘,homedir),              

CONCAT(‘/home/domains/‘,maildir),              

quota,                                         

name                                            

FROM mailbox                                   

WHERE username = ‘$(local_part)@$(domain)‘

3.4 配置webmail 3.4.1 配置apache2

#vi /etc/apache2/sites-enabled/vip.eol.cn

<VirtualHost *>

          ServerName   mail.vip.eol.cn

         DocumentRoot /var/www/extsuite/extmail/html

         ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi

         Alias        /extmail   /var/www/extsuite/extmail/html

         ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi

         Alias        /extman /var/www/extsuite/extman/html

         SuexecUserGroup  postfix postfix

        <Directory /var/www/extsuite>

        Options Indexes FollowSymLinks

        AllowOverride None

        Allow from all

        </Directory>

</VirtualHost>

注意:suexec模块安装的时候,debian默认用户为www-data,目录为/var/www目录,手工编译安装可以自己指定参数

# ln -s /etc/apache2/mods-available/suexec.load  /etc/apache2/mods-enabled/

34.2 配置extmail/extman

 导入数据库:

#cd /opt/distfiles/

#tar zxvf extman-1[1][1].0.1.tar.gz

#cd extman-1.0.1/docs/

#mysql -uroot <  extmail.sql

#mysql -uroot <  init.sql

说明:

此时已经创建了extmail数据库,并授权了extmail/extmail和webman/webman帐户,默认extman管理账号为root@extmail.org/extmail*123*

# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

# chown -R postfix.postfix /var/www/extsuite/extman/cgi/

#mkdir /var/www/ extsuite

#mv /opt/distfiles/extmail /var/www/extsuite

#mv /opt/distfiles/extman /var/www/extsuite

配置extmail

#cd /var/www/extsuite/extmail

#cp webmail.cf.default webmail.cf

#vi webmail.cf

修改其中的数据库配置和smtp服务器配置以及默认语言配置:

SYS_USER_LANG = zh_CN

SYS_CRYPT_TYPE = md5crypt

SYS_MYSQL_USER = extmail

SYS_MYSQL_PASS = extmail

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = 219.224.99.244

SYS_MYSQL_SOCKET = /var/run/mysqld/mysqld.sock

#mkdir /home/domains

# chown -R postfix.postfix /home/domains/

配置extman

#cd /var/www/extsuite/extman

#cp  webman.cf.default webman.cf

SYS_LANG = zh_CN

SYS_MYSQL_USER = webman

SYS_MYSQL_PASS = webman

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET =  /var/run/mysqld/mysqld.sock

图形日志:

注意:

   debian的邮件日志为/var/log/mail.log,而mailgraph-init脚本定义的日志为mailog,需要手工修改,或者链接一个文件,建议修改脚本中的配置为MAIL_LOG=/var/log/mail.log

#cp Cr /var/www/extsuite/extman/addon/mailgraph_ext /usr/local/

# /usr/local/mailgraph_ext/mailgraph-init start

#/var/www/extsuite/extman/daemon/cmdserver --daemon