您的位置:首页 > 大数据 > 人工智能

Postfix-courier-authlib-cyrus-sasl-courier-imap-maildrop-extmail-extman源码安装

2012-08-17 15:17 591 查看
一 系统运行环境

1.1 硬件要求

基本上, 能够安装linux 系统就能够满足硬件的要求…….

1.2 运行环境

操作系统为RHEL5.3+VMware-workstation6.0.

我使用的VM6虚拟机和 RHEL5.3 做的本次试验.

1.3 所需软件

1, RHEL 服务器操作系统

2, Postfix 邮件服务器系统的 smtp 服务器, 在邮件服务器系统中充当MTA角色.

3, Mysql 开源数据库,用于存储邮件系统虚拟域, 虚拟帐户信息.

4, apache web 服务器软件, 用于extman 对邮件系统的后台管理,extmail的web邮件收发.

5, php extman 和extmail 需要使用 php 解析

6, cyrus-sasl 用于实现身份验证的smtp 服务器

7, courier-authlib 现实带验证的 pop3 服务器

8, courier-imap 用于实现pop3,imap收邮件功能

9,extman 用于邮件服务器的后台管理

10,extmail 用于实现 webmail

11,DBD-mysql 用于解决依赖关系,extmail将会用到

12,unix-syslog 用于解决依赖关系,extmail将会用到

13,BerkeleyDB 用于提供数据库效率

14, openssl 提供安全的邮件服务器连接 ( 本次试验未配置此功能)

15, maildrop 用于替代postfix 的mta 功能, 邮件投递代理, 将收到的邮件转发到用户的邮箱目录(本次试验未配置此功

能)

16,clamav 反病毒工具 (本次试验未配置此功能)

17,SpamAssassin 反垃圾邮件过滤器 (本次试验未配置此功能)

18,amavisd-new 是一个连接MTA和内容检测工具 (本次试验未配置此功能)

二、准备工作:

1、关闭 selinux

2、卸载sendmail rpm -e --nodeps sendmail

或者:

停用sendmail

#service sendmail stop

#chkconfig --level 345 sendmail off

#mv /usr/bin/newaliases /usr/bin/newaliases.orig

#mv /usr/bin/mailq /usr/bin/mailq.orig

#mv /usr/sbin/sendmail /usr/sbin/sendmail.orig

3、卸载mysql 自定义安装mysql

安装完后复制 libmysqlclient.so.15 文件,否则安装postfix会报错

cp /usr/local/mysql/lib/libmysqlclient.so.15 /usr/lib

4、卸载自带sasl

rpm -qa | grep sasl

rpm -e --nodeps cyrus-sasl-plain cyrus-sasl-lib cyrus-sasl

或者:

关闭原有的sasl:

# mv /usr/lib/libsasl2.a /usr/lib/libsasl2.a.OFF

# mv /usr/lib/libsasl2.la /usr/lib/libsasl2.la.OFF

# mv /usr/lib/libsasl2.so.2.0.19 /usr/lib/libsasl2.so.2.0.19.OFF

# mv /usr/lib/sasl2 /usr/lib/sasl2.OFF

# rm /usr/lib/libsasl2.so

# rm /usr/lib/libsasl2.so.2

5、卸载自带postfix

rpm -e postfix-2.3.3-2.1.el5_2

6、确保系统有运行时所需要的用户和组

用户名 组名 作用 备注

mysql mysql 数据库mysql 运行用户

vmta vmta 虚拟邮件帐号所使用用户及组 uid:1000,gid:1000

postfix postfix postfix主程序使用帐号和组

postdrop postfix setid_group setgid_group=postdrop

useradd vmta -u 1000 -s /sbin/nologin

usermod -G postfix vmta

#groupadd -g 1000 postdrop

#useradd -g postdrop -u 2526 -s /bin/false -M postdrop

# 这里有2 个值得注意的地方,他们是 vmta用户, 组及postdrop. 在postfix 邮件系统中,有好几个程序是以extmail来运行,postdrop 是postfix主配置文件main.cf里标明的, setgid_group=postdrop.

三、源码安装

==================安装mysql、apache、php=====================

修改apache配置文件

vi httpd.conf

更改User:

User vmta

Group vmta

导入extmail数据库

/usr/local/mysql/bin/mysql -uroot -p < /root/meng/extman-1.1/docs/extmail.sql

/usr/local/mysql/bin/mysql -uroot -p < /root/meng/extman-1.1/docs/init.sql

导入数据库里面的两个系统账号密码:

root@extmail.org,密码为 extmail*123*

postmaster@extmail.org,密码为 extmail

------设置FQDN---------------------------------

vi /etc/hosts

加入:

192.168.24.90 mail.ipanel.cn mail

127.0.0.1 localhost.localdomain localhost

vi /etc/rc.local

加入:

hostname mail.ipanel.cn

vi /etc/sysconfig/network修改HOSTNAME的值:

HOSTNAME=mail.ipanel.cn

=====================安装coutier-authlib=======================

tar jxvf courier-authlib-0.62.4.tar.bz2

cd courier-authlib-0.62.4

#–prefix=/usr/local/courier-authlib \ \\安装的位置

#>–without-stdheaderdir \ \\将头文件安装到一个不是默认的头文件搜索路径的目录中

#>–with-authmysql \ \\配置支持MYSQ数据库查询

#>–with-redhat \ *******注意redhat安装时一定需要--with-redhat选项否则有可能报错*****

#>–with-mysql-libs=/usr/local/mysql/lib/mysql \ \\mysql的库文件路径

#>–with-mysql-includes=/usr/local/mysql/include/mysql \\msyql 的头文件路径

一个关键点:

如果courier-authlib安装到非标准位置(例如安装到/usr/local下),一定记得在./configure时增加-- without-stdheaderdir,这样以后在编译Courier-IMAP和maildrop的时候,不用特别指定courier- authlib的库文件位置,这里没有用,所有装imap是要指明库文件

本次编译参数

./configure --prefix=/usr/local/courier-authlib --without-authpam --without-authdap --without-authshadow --without-vchkpw --with-authmysql --with-mysql-libs=/usr/local/mysql/lib --with-mysql-includes=/usr/local/mysql/include --with-redhat

make

make install

chmod +x /usr/local/courier-authlib/var/spool/authdaemon

cd /usr/local/courier-authlib/

chmod -R 755 var/spool/authdaemon/

cd etc/authlib/

cp authdaemonrc.dist authdaemonrc

cp authmysqlrc.dist authmysqlrc

vi authdaemonrc ###主配置,设置使用的认证方式

修改/etc/authdaemonrc 文件为:

authmodulelist="authmysql"

authmodulelistorig="authmysql"

daemons=10

vi authmysqlrc ###数据库配置,设置连接地址、查询方式等

修改/etc/authmysqlrc 为以下内容,其中1000 ,1000 为vmta 用户的UID 和GID 。

MYSQL_SERVER localhost

MYSQL_PORT 3306 (指定你的mysql 监听的端口,这里使用默认的3306)

MYSQL_USERNAME postfix (数据库管理员账号 )

MYSQL_PASSWORD ipanell (数据库管理员账户密码 )

MYSQL_SOCKET /tmp/mysql.sock

MYSQL_DATABASE extmail //虚拟用户数据库

MYSQL_USER_TABLE mailbox //重mailbox表中获得账户的信息

MYSQL_CRYPT_PWFIELD password //从pssword字段获得帐户密码

MYSQL_UID_FIELD '1000' //1000为虚拟用户vmta的 uid

MYSQL_GID_FIELD '1000' //1000为 虚拟用户vmta的组gid

MYSQL_LOGIN_FIELD username //从username字段获得帐户名称(带@后缀)

MYSQL_HOME_FIELD concat('/home/mailusers/',homedir) //用户的宿主目录完整路径

MYSQL_NAME_FIELD name //从name字段获得帐户名称(不带@后缀)

MYSQL_MAILDIR_FIELD concat('/home/mailusers/',maildir) //合并出用户的完整邮件存储路径

将courier-authlib的库文件路径添加到系统的搜索路径中去

echo "/usr/local/courier-authlib/lib/courier-authlib">>/etc/ld.so.conf

ldconfig

设置开机自启动:

cp /root/meng/courier-authlib-0.62.4/courier-authlib.sysvinit /etc/init.d/courier-authlib

chmod 755 /etc/init.d/courier-authlib

chkconfig --add courier-authlib

chkconfig --level 345 courier-authlib on

service courier-authlib start

新建虚拟用户邮箱所在的目录,并将其权限赋予vmta用户:

cd /home

mkdir mailusers

chown -R vmta:vmta mailusers

====================安装cyrus-sasl=======================

cd /root/meng/

tar xzvf cyrus-sasl-2.1.25.tar.gz

cd cyrus-sasl-2.1.25

./configure --prefix=/usr/local/sasl2 --disable-gssapi --disable-anon --disable-digest --enable-plain --enable-login --enable-sql --with-mysql=/usr/local/mysql/ --with-mysql-includes=/usr/local/mysql/include/ --with-mysql-libs=/usr/local/mysql/lib/ --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket

make

make install

postfix 2.3以后的版本会分别在/usr/local/lib和/usr/local/include中搜索sasl库文件及头文件,故还须将其链接至此目录中:

ln -sv /usr/local/sasl2/lib/* /usr/local/lib

ln -sv /usr/local/sasl2/include/sasl/* /usr/local/include

ln -sv /usr/local/sasl2/lib/sasl2 /usr/lib/sasl2

配置sasl:

创建运行时需要的目录并调试启动:

mkdir -pv /var/state/saslauthd

在/var/ 目录下建一个目录给saslauthd 进程存在临时数据。假如没有这些目录,运行saslauthd 时,会提示出错。

接着为确保CYRUS-SASL2函数库知道怎样验证所收来的SASL 认证请求,必须创建一个SASL 的配置文档。配置文档名为smtpd.conf 位于/usr/local/sasl2/lib/sasl2 这个目录,在该文档中您定义您希望使用的认证数据库方法,以下这个例子使用

saslauthd 来验证认证请求.

vi /usr/local/sasl2/lib/sasl2/smtpd.conf

添加以下内容,切记冒号后面没有空格,否则测试不通过

pwcheck_method:saslauthd

mech_list:PLAIN LOGIN

设置认证日志文件

vi /usr/local/courier-authlib/etc/authlib/authdaemonrc

DEBUG_LOGIN=2 原来默认是打开日志信息

vi /etc/syslog.conf

添加:

*.debug /var/log/debug.log

启动并测试sasl:

/usr/local/sasl2/sbin/saslauthd -a shadow pam -d 自动

/usr/local/sasl2/sbin/saslauthd -a shadow pam -d & 后台运行

/usr/local/sasl2/sbin/testsaslauthd -u root -p ipanel

显示:0: OK "Success." 就说明saslauthd 正常运行了

testsaslauthd 程式默认是没有编译的,您需要在源码目录树的saslauthd子目录中运行

# make testsaslauthd 命令生成。

添加连接库 postfix 编译安装会用到, 否则报错.

echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf

echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf

ldconfig

因为postfix会到/usr/lib 目录下去找SASL2库,而我们是把程式安装在/usr/local/sasl2 中,所以我们要在/usr/lib 目录下做一个链接:放到/usr/lib 下, 否则为postfix开启基于cyrus-sasl的认证功能时才 Ok:

ln -sv /usr/local/sasl2/lib/sasl2/ /usr/lib/sasl2 ####前面已经做过这步骤了。

开机自动启动

echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam">>/etc/rc.local

================安装postfix========================

安装postfix ,编译时出错用高版本postfix-2.6.0后无报错,

tar -zxvf postfix-2.6.0.tar.gz

cd postfix-2.6.0

make -f Makefile makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2'

make

make install

交互模式安装

Install_root: [/]/

tempdir: [/usr/local/src/ postfix-2.4.5]/tmp

config_directory: [/etc/postfix] /etc/postfix

command_directory: [/usr/sbin] /usr/local/postfix/sbin

daemon_directory: [/usr/libexec/postfix] /usr/local/postfix/libexec

data_directory: [/var/lib/postfix]

queue_directory: [/var/spool/postfix] /var/spool/postfix

sendmail_path: [/usr/sbin/sendmail] /usr/sbin

newaliases_path: [/usr/bin/newaliases] /usr/bin/newaliases

mailq_path: [/usr/bin/mailq] /usr/bin/mailq

mail_owner: [postfix] postfix

setgid_group: [postdrop] postdrop

html_directory: [no] no

manpages: [/usr/local/man] /usr/local/postfix/man

readme_directory: [no] no

按以上选项安装postfix

生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:

[root@localhost postfix-2.6.0] newaliases

#这个必须执行, 否则后面会报错fatal: open database /etc/aliases. db: No such file or directory

cd /usr/local/postfix

vi /etc/postfix/main.cf

修改以下几项为您需要的配置

myhostname = mail.drvial.com

myorigin = mydomain

mydomain = drvial.com

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mynetworks = 192.168.2.0/24, 127.0.0.0/8

inet_interfaces = all

设置用Maildir/的风格投递到本地用户(不能掉后面的/)

home_mailbox = Maildir/

设置自启动:

echo "/usr/local/postfix/sbin/postfix start">>/etc/rc.local

/usr/local/postfix/sbin/postfix start

日志警告:warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

解决:找到/etc/postfix/main.cf 文件中的alias_maps = hash:/etc/aliases 去掉#

连接 postfix ,验正服务启动状况:

telnet localhost 25

ehlo mail.drvial.com

mail from:root@drvial.com

rcpt to:drvial@drvial.com

data

subject:Mail test!

Mail test!!!dfdddd

.

quit

=================为postfix添加CYRUS-SASL认证====================

为postfix 开启基于 cyrus-sasl 的认证功能

使用以下命令验正postfix是否支持cyrus 风格的sasl 认证,如果您的输出为以下结果,则是支持的:

/usr/local/postfix/sbin/postconf -a

vi /etc/postfix/main.cf

在最后添加以下内容:

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,rej ect_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_local_domain = $myhostname

smtpd_sasl_security_options = noanonymous

smtpd_sasl_application_name = smtpd

smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

为postfix开启sasl认证机制

vi /usr/local/lib/sasl2/smtpd.conf

添加如下内容:

pwcheck_method:saslauthd

mech_list:PLAIN LOGIN

/usr/local/postfix/sbin/postfix reload

////////////////////////各个参数含义/////////////////////////////////////////////////////////////

以smtpd_sasl*开头的表示smtp server的参数

以smtp_sasl*开头的表示smtp client的参数。

对于服务器端的配置,你至少需要设定smtpd_sasl_auth_enable参数,并且将permit_sasl_authenticated限制条件列在某一个smtpd_*_restriction的过滤规则里。

smtpd_sasl_auth_enable = yes 这是激活sasl支持.假如您改成 no sasl功能也会停 止运作!

smtpd_sasl_local_domain = $myhostname 指 sasl 预设 domain ,假如你不使用sasldb方式治理密码的话, 请设定 $myhostname ,(主要因为sasldb治理方式,自行可以设定. )

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_relay_domains 指使用认证的设定(请保持上列为一行 , 没有断行)

a.permit_mynetworks 答应 mynetworks (postfix设定.)

b.permit_sasl_authenticated 答应具有 sasl 认证设定( sasldb,....)

c.check_relay_domains 确认relay的区域 (postfix设定.)

smtpd_sasl_security_options = 指 sasl 安全选项,任何一项不通过信件都可能造成信件无法送出.

a.noanonymous 这里是答应任何非匿名认证方法。

b. noplaintext 指不使用 PLAIN 和 LOGIN 方式

c. nodictionary

d. noactive

另外二个

broken_sasl_auth_clients = yes 容许你接受这种不遵守规定的行为,设定此参数之后,postfix会分别以标准与非标准两种格式来列出它所支持的smtp验证机制

#client

smtp_sasl_auth_enable = yes

这二个支持client端的服务

主要是针对客户端的连结软件个区隔,例如 outlook4大概很少人用了吧.所以 broken_sasl_auth_clients 就当没看到吧

smtpd_sender_login_maps = hash:/etc/postfxi/sasl_senders 【避免寄件人冒名】,设定寄件地址与sasl登录身份的对应关系,假设某人的邮件地址是kdent@example.com,其sasl登录身份为kdent,如果你希望kdent只能以该地址的名义来发邮件,而不能使用其他寄件地址,你应该将下列对应关系定义在一个查询表中:sasl_senders

下一步是将reject_sender_login_mismatch限制条件纳入某个smtpd_*_restrictions过滤规则组合里,这样一 来,如果kdent通过sasl验证,但是他却试图以mary@example.com的名义寄出邮件,那么postfix将拒绝帮他寄信。

permit_sasl_authenticated 【 核准授权用户】

如果你的ube过滤规则里包含了smtpd_recipient_restrictions,你得使postfix准许通过验证得用户使用转发服务,也就是将permit_sasl_authenticated安插在限制条件里得适当位置。

smtpd_asal_security_options = noanonymous, noplaintext 【设定验证机制】

当客户端联机到smtp server时,哪些密码验证机制可使用,由smtpd_sasl_security_options参数决定。完整得机制选项,取决于你得系统上有哪些机制可用以及你得sasl函数库支持哪些机制。如果不指定任何选项,默认值是接受包括明文密码在内得所有可用机制,但匿名登录除外。如果使用了 saslauthd daemon,就必须接受明文密码,所以,默认值的设想是合情合理的。如果你指定了任何选项,则默认值无效,所以你的选项里必须包含 noanonymous。

例如:smtpd_asal_security_options = noanonymous, noplaintext

///////////////////////////////////////////////////////////////////////////////////////////

添加smtp认证后测试:

telnet localhost 25

Trying 127.0.0.1...

Connected to mail.drvial.com (127.0.0.1).

Escape character is '^]'.

220 Welcome to our mail.drvial.com ESMTP,Warning: Version not Available!

ehlo mail.drvial.com

250- mail.drvial.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN (请确保您的输出以类似两行)

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

====================Virtual Mailbox Settings============

配置postfix 以支持虚拟域和虚拟用户

virtual_mailbox_base = /home/mailusers

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

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

virtual_alias_domains =

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

virtual_uid_maps = static:1000 #1000 为你添加的vmta用户uid

virtual_gid_maps = static:1000 #1000 为你添加的vmta组gid

virtual_transport = virtual

maildrop_destination_recipient_limit = 1

maildrop_destination_concurrency_limit = 1

注意的地方是 virtual_uid_maps 及virtual_gid_maps 的值,它是 vmta 用户的uid 和postfix 组的gid, 与前面的文件

/usr/local/courier-authlib/etc/authlib/authmysqlrc的"MYSQL_UID_FIELD""MYSQL_GID_FIELD"一定要保持一致

-------------------------------QUOTA Settings-----------------------

1、邮件容量限制:

message_size_limit = 14336000

virtual_mailbox_limit = 20971520

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/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 Tidy your mailbox and try again later.

virtual_overquota_bounce = yes

2、添加为支持虚拟域和虚拟用户所用到的配置文件, 以下4 个配置文件是不存在的,

或者拷贝从/root/meng/extman-1.1/docs 这四个文件。改下数据库帐户密码即可。

cp /root/meng/extman-1.1/docs/mysql_virtual_* /etc/postfix/

vi /etc/postfix/mysql_virtual_alias_maps.cf

添加如下内容:

user = postfix

password = ipanel

hosts = localhost

dbname = extmail

table = alias

select_field = goto

where_field = address

vi /etc/postfix/mysql_virtual_domains_maps.cf

添加如下内容:

user = postfix

password = ipanel

hosts = localhost

dbname = extmail

table = domain

select_field = description

where_field = domain

vi /etc/postfix/mysql_virtual_mailbox_limit_maps.cf

添加如下内容:

user = postfix

password = ipanel

hosts = localhost

dbname = extmail

table = mailbox

select_field = quota

where_field = username

vi /etc/postfix/mysql_virtual_mailbox_maps.cf

添加如下内容:

user = postfix

password = ipanel

hosts = localhost

dbname = extmail

table = mailbox

select_field = maildir

where_field = username

#以上新建文件也可以从extman 安装文件中获得,您也可以由此不用手动输入;

#虚拟用户邮箱目录我这里 /home/mailusers ,你可以指定为别的目录,比如常见到的/var/mailbox,或者

/home/domains 等;但如果这里做了修改,请在后文中用到时作了相应的修改;

=================编译courier-imap:===================

tar -jxvf courier-imap-4.5.1.tar.bz2

cd courier-imap-4.5.1

./configure --prefix=/usr/local/courier-imap --enable-unicode --disable-root-check --with-trashquota --without-ipv6 CPPFLAGS='-I/usr/local/courier-authlib/include' LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib' COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'

make && make install

cd /usr/local/courier-imap/

cp ./etc/imapd.dist ./etc/imapd

cp ./etc/imapd-ssl.dist ./etc/imapd-ssl

cp ./etc/pop3d.dist ./etc/pop3d

cp ./etc/pop3d-ssl.dist ./etc/pop3d-ssl

配置Courier-IMAP,为用户提供 pop3 服务

vi ./etc/pop3d

POP3DSTART=YES

注:如果你想为用户提供IMAP 服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes" ;其它类同;

设置开机启动

cd /root/meng/courier-imap-4.5.1/

cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imapd

chmod 755 /etc/rc.d/init.d/courier-imapd

chkconfig --add courier-imapd

chkconfig --level 2345 courier-imapd on

service courier-imapd start

/etc/init.d/courier-authlib restart

测试Courier- Authlib是否能成功连接mysql:

/usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail

如果成功应该有如下显示

Authentication succeeded.

Authenticated: postmaster@extmail.org (uid 1000, gid 1000)

Home Directory: /home/vmail/extmail.org/postmaster

Maildir: /home/vmail/extmail.org/postmaster/Maildir/

Quota: 104857600S

Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0

Cleartext Password: extmail

Options: disablesmtpd=0,disablesmtp=0,disablewebmail=0,disablenetdisk=0,disableimap=0,disablepop3=0,netdiskquota=52428800S

测试pop3是否通过:

测试前先手动新建邮箱目录,否则报错:postmaster@extmail.org: chdir(/home/mailusers/extmail.org/postmaster) failed!! mail pop3d: error: No such file or directory

mkdir -p /home/mailusers/extmail.org/postmaster/Maildir/cur

telnet localhost 110

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

+OK Hello there.

user postmaster@extmail.org

+OK Password required.

pass extmail

+OK logged in.

quit

+OK Bye-bye.

Connection closed by foreign host.

接下来重新配置SMTP 认证,编辑 /usr/lib/sasl2/smtpd.conf

vi /usr/lib/sasl2/smtpd.conf (以上几个smtpd.conf其实链接的一个文件)

确保smtpd.conf其为以下内容:

pwcheck_method:authdaemond

log_level:3

mech_list:PLAIN LOGIN

authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

确认修改目录的权限,否则postfix无法获得用户名和密码

chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/

测试:虚拟用户的smtp发信认证

首先获得虚拟用户postmaster@extmail.org的用户名和密码的BASE64编码字符串

#perl -e 'use MIME::Base64;print encode_base64("postmaster\@extmail.org")'

cG9zdG1hc3RlckBleHRtYWlsLm9yZw==

#perl -e 'use MIME::Base64;print encode_base64("extmail")'

ZXh0bWFpbA==

[root@drvial extman]# telnet localhost 25

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

220 Welcome to our mail.drvial.com ESMTP,Warning:Version not Available!

ehlo mail.drvial.com

250-mail.drvial.com

250-PIPELINING

250-SIZE 14336000

250-VRFY

250-ETRN

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

auth login

334 VXNlcm5hbWU6

cG9zdG1hc3RlckBleHRtYWlsLm9yZw== ###输入用户名

334 UGFzc3dvcmQ6

ZXh0bWFpbA== ###密码

235 2.7.0 Authentication successful # 正常

quit

221 2.0.0 Bye

Connection closed by foreign host.

若还是提示cannot connect to Courier authdaemond: Permission denied ,重启Courier- Authlib试试

==============编译安装maildrop:===============

把maildrop 与 courier-authlib 关联:

ln -s /usr/local/courier-authlib/bin/courierauthconfig /usr/bin/courierauthconfig

./configure --prefix=/usr/local/cyrus-sasl --disable-sample --disable-saslauthd --disable-pwcheck --disable-cram --disable-digest --disable-krb4 --disable-gssapi --disable-anon --enable-plain --enable-login --enable-sql --disable-ntlm --disable-otp --disable-srp --disable-srp-setpass --with-authdaemond=/var/spool/authdaemon/socket

make && make install

ln -s /usr/local/cyrus-sasl/lib/sasl2 /usr/lib/sasl2

==============安装extman=====================

tar xzvf extman-1.1.tar.gz

mv extman-1.1 extman

mv extman /var/www/

cd /var/www/extman

cp webman.cf.default webman.cf

vi webman.cf

修改:

SYS_CONFIG = /var/www/extman/

SYS_LANGDIR = /var/www/extman/lang

SYS_TEMPLDIR = /var/www/extman/html

修改以下mysql参数:

SYS_MYSQL_USER = postfix

SYS_MYSQL_PASS = ipanel

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /tmp/mysql.sock

vi /usr/local/apache2/conf/httpd.conf

修改

User apache

Group apache



#User apache

#Group apache

User postfix

Group postfix

增加

### abiao start

ScriptAlias /extman/cgi/ "/var/www/extman/cgi/"

<Directory "/var/www/extman/cgi">

AllowOverride None

Options None

Order allow,deny

Allow from all

</Directory>

Alias /extman /var/www/extman/html

### abiao end

cd /tmp

mkdir extman

chown vmta:vmta extman

service httpd restart

可以访问http://192.168.10.22/extman/了

碰到:验证码图片不显示时,需要先安装这个rpm:

rpm -ivh perl-GD-2.35-1.el5.rf.i386.rpm

或者可以配置extman/webman.cf中SYS_CAPTCHA_ON = 0 #取消校验码,1为使用校验码,

如果extman web页面信息显示No such file or directory

启动cmdsever

/var/www/extman/daemon/cmdserver -d

开机启动

echo "/var/www/extman/daemon/cmdserver -d" >>/etc/rc.local

#如果apache后台日志出现[error] [client 192.168.24.16] Prototype mismatch: sub Encode::IMAPUTF7::decode ($$;$) vs none at /var/www/extman/libs/Encode/IMAPUTF7.pm line 76.

此报错不影响使用

解决方法:

cp /var/www/extman/libs/Encode/IMAPUTF7.pm IMAPUTF7.pm.bak

拷贝新下载的IMAPUTF7.pm

cp /mnt/win/postfix/Encode-IMAPUTF7-1.04.tar.gz /root/meng/

cd meng/

tar xzvf Encode-IMAPUTF7-1.04.tar.gz

cp Encode-IMAPUTF7-1.04/lib/Encode/IMAPUTF7.pm /var/www/extman/libs/Encode/

===========安装extmail====================

tar xzvf extmail-1.2.tar.gz

mv extmail-1.2 extmail

mv extmail /var/www/

cd /var/www/extmail

cp webmail.cf.default webmail.cf

vi webmail.cf

修改:

SYS_CONFIG = /var/www/extmail/

SYS_LANGDIR = /var/www/extmail/lang

SYS_TEMPLDIR = /var/www/extmail/html

SYS_LOG_TYPE = file

SYS_LOG_FILE = /var/log/extmail.log

SYS_MAILDIR_BASE = /home/mailusers

SYS_CRYPT_TYPE = plain-md5 这个加密方式必须跟mysql的加密方式一致 不然无法验证密码

修改以下mysql参数:

SYS_MYSQL_USER = postfix

SYS_MYSQL_PASS = ipanel

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /tmp/mysql.sock

touch /var/log/extmail.log

chown vmta:vmta /var/log/extmail.log

vi /etc/httpd/conf/httpd.conf

增加

### abiao start

ScriptAlias /extmail/cgi/ "/var/www/extmail/cgi/"

<Directory "/var/www/extmail/cgi">

AllowOverride None

Options None

Order allow,deny

Allow from all

</Directory>

Alias /extmail /var/www/extmail/html

### abiao end

service httpd restart

可以访问http://192.168.10.22/extmail/了

碰到:Unix::Syslog not found, please install it first! 错误时,需要先安装这个rpm:

rpm -ivh perl-Unix-Syslog-0.100-1.2.el5.rf.i386.rpm

===========================================================

====================postfix权威指南笔记======================

反垃圾邮件软件:Mail-Spamassassin-3.2.3.tar.gz

邮件杀毒软件:clamAV

linux实现安全邮件服务的优秀组合:postfix+Amavis+ClamAV+Spammassassin

测试软件:bind自带的queryperf

邮件传输代理MTA(mail transfer agent):

负责接受和发送邮件

代表软件:sendmail、postfix、qmail

邮件分发代理MDA(mail delivery agent):

功能:本地投递、中转到其他MTA、邮件过滤、黑白名单、自动分类等

代表软件:Binmail、Procmail、Maildrop

邮件用户代理MUA (mail user agent)

负责收取邮件主机中的邮件

代表软件:sqwebmail、openwebmail、igenus

------------------------------

标头里的收件人地址与“信封地址”无关

一封信可分成两大部分:标头(header)与正文(body)。标头含有许多特定名称的字段如To: From: Subject:

标头与正文之间以一个空白行为分界

monolithic 单体式设计

modular 模块化设计

component 组件

process 进程

relay 网络收下要寄到其他网域的邮件,并代为寄送到目的地的动作称为转发(relay)

delivery 投递

无法送达通知函

当用户的邮件被延时,或是根本无法递送到目的地时,postfix使用defer或bounce daemon 产生一封跌送状态的通知函,这封通知函会被交给cleanup daemon,由它进行例行清理之后再排入邮件队列,由queue manager 处理

队列管理

每个能收到邮件的postfix组件都有一个共同的目的---queue manager ,只有经过cleanup daemon 清理过的邮件,才会进入队列,邮件到达列队管理器后,就会用trivial-rewrite来决定邮件路由信息,包括传输方法,下一站以及收件人地址。

pickup daemon 每当有新邮件进入maildrop/时,pickup daemon便会读出新邮件,然后交给cleanup daemon进行清理程序。

队列管理单元的服务器程序-----qmgr daemon,

必要时管理员可以用postsuper和postqueue自己手动管理

默认队列目录一般在/var/spool/postfix/下面

队列管理器总共设置了五个不同用途的队列:

incoming 输入队列----每当有新信进入收件队列

active 活动队列

deferred 等待队列----暂时无法送出的邮件会被放在等待队列

corrupt 故障队列----用于存放受损或无法解读的邮件

hold 保留队列----将疑为垃圾邮件留在队列里,此队列不是靠queue 来管理,而是必须管理员手动管理。

默认队列目录一般在/var/spool/postfix/下面

queue_minfree

postfix邮件系统的第一站是“输入队列",queue_minfree 参数来保护队列文件系统,此参数的默认值为0,表示qmgr可以无限制地使用队列磁盘空间。如果你不想队列耗尽服务器的磁盘空间,建议你设定一个合理的上限值。

bounce_size_limit

退信通知函与遭退邮件的总和大小不得超过此值

--------------------队列管理工具

postqueue -p 查看列出队列里的所有邮件

postqueue -f 刷新队列命令可以将队列中的所有邮件重新投递。

postsuper-d ***(Queue ID栏的标示符) 删除列队里面的邮件

postsuper -d ALL 删除列队里面所有的邮件

postsuper -h Queue ID 将指定的邮件搬到保留队列,-H 将邮件移回原来的列队

postsuper -r Queue ID 重置指定邮件队列

postsuper -r ALL 将全部邮件重新排队

postcat -q Queue ID 查看一个队列文件的内容

postqueue -i 635AF8E61A 如果队列中指定的邮件需要投递,可以使用下面命令。

设置接收快速清空的资格:

fast_flush_domains=$relay_domains example.com *************

postqueue -s example.com 清空所有邮件(有被清空资格的网域)

--------------------------------

参数设置:

maximal_queue_lifetime

如果邮件在等待队列里的时间超过此上线postfix便会投递放弃,默认为5天

queue_run_delay

扫描内部队列的时间间隔,默认1000s

maximal_backoff_time

minimal_backoff_fime

postfix重新投递等待邮件的频繁程度的上下限

设置MDA进程数

default_process_limit

MDA第一次最多只能同时送出多少封邮件默认为5

initial_destination_concurrency

bounce_size_limit=50000b

退信通知函与遭退邮件的总和不得超过此值,如果超过此限制,则原寄件人只会收到退信通知函,而不会收到遭退邮件本身

对于每一种类型的错误通知函,都有一个对应的class_notice_recipient

initial_destination_concurrency

如果有多封邮件要送到同一个目的地,MDA第一次最多只能同时送出邮件的封数,默认为5,

default_destination_concurrency_limit 同时投递的邮件数,默认20

提升本地邮件的同时投递量

mda_destination_concurrency_limit

local_destination_concurrency_limit

smtp_destination_concurrency_limit

mda_destination_recipient_limit

如果想收到所有问题的通知函,请照下面这样设定notify_classes参数

notify_classes = bounce, 2bounce, delay, policy, protocol, resource, software

-------------------------------------

postconf 可以查阅、修改postfix系统的各项参数的设定值

postconf -e myhostname=mail.liutest.com ## -e编辑参数

postconf -l 查看系统提供了哪些锁定机制

postconf -m 查看postfix支持哪些类型的查询表

postmap 常见实际查询之用的数据文文件

postmap -q 指定你要查询的LHS

NIS 一种专用来记录用户信息的网络数据库

倘若你的系统提供NIS服务,但是你不想使用它,你可以修改alias_maps参数,让他只包括别人文件:alias_maps = hash:/etc/aliases

postfix check 检查postfix是否有问题

egrep '(reject|warning|error|fatal|panic):' /var/log/maillog 快速查看日志有错误的地方

邮箱目录使用maildir风格时,其他有三个子目录

tmp/ MDA将邮件内容储存成文件,在确定全部内容都写入文件之后,邮件文件会被搬到new/下面

new/ 存放MDA已经送达但是尚未被用户阅读的信

cur/ 用户看过邮件之后,邮件会被转移到cur/下面

----------------------------------------------

第七章:本地投递

本地邮件(local):

凡是收件地址的网域名称与mydestination参数列出的任一网域名称相符,这类邮件都算是本地邮件。这类本地邮件由local MDA负责投递。对于送到任何mydestination网域的任何有效账户的邮件,local MDA 会先检查收件人是否有个人的.forward文件,如果没有,则邮件会被存入用户的个人邮箱;否则,则依据.forward文件的内容来进行投递操作(或转寄到其他地方,或是交给外部程序处理)

转发邮件(relay):

邮件终点站是relay_domains参数所列出的网域之一,postifx就视其为转发邮件,由relay MDA啦执行投递任务。

虚拟(virtual):

如果要同时服务多个网域,则额外的网域称为虚拟网域虚拟网域的邮件由virtualMDA负责投递

postconf -l 查看系统支持哪几种锁定机制

--------------------------------------

收信限制参数:

smtpd_recipient_limit 参数决定一封邮件最多可以有几位收件人,默认值1000。就一般的邮件系统而言,这是很宽松的限制。

message_size_limit 参数限制单封邮件的容量上限。默认值为10M。如果想节约磁盘空间或内存,建议你降低此值。但如果你的用户经常夹带大的图像文件,则应该考虑适度扩大此值。

客户端连接服务器限制:

smtp_error_sleep_time =1s

smtp_soft_error_limit=10

smtp_hard_error_limit=20

每次客户端出错之后, postfix都只会延迟1秒钟(smtp_error_sleep_time),在历经十次试探之后(smtp_soft_error_limit) ,postfix开始延长每次延迟的时间。在第十一次错误时,postfix等待11秒;第十二次则等待12秒,依此类推。 当总错误次数到达二十次(smtp_hard_error_limit postfix)便有充分理由认定对方另有所图,所以会立刻切断连接。如果对方再次连接,而且试图制造同样麻烦,则他势必再经历一回漫长的等待。

地址自动补齐参数:

append_at_myorigin

append dot mvdoain

规范表:

canonical_maps=hash:/etc/postfix/canonical

canonical_maps参数会影响所有地址,包括信封与标头里的地址。每当postfix 发现邮件地址符合规范表的某索引键,便会将它改写成对应值。如果你只想修改收件人或发信者的地址,postfix提供了额外的参数:sender_canonocal_maps 与recipient_canonical_maps。这两个参数的工作方式与canonical_maps相同,但是只会影响相关的地址。如果你同时设定了这三个参数, postfix会依照下列顺序来改写地址:先是sender_canonical_maps,然后是recipient_canonical_maps ,最后才是canonical_maps。

伪装主机名称:

masquerade_domains=example.com

如:me@host.domain.com 会别转换成me@domain.com

改变投递地址:

relocated_maps=hash:/etc/postfix/relocated

处理不明用户:

local_recipient_maps=

luser_relay=catchall

更改根目录(chroot)

queue_directory

-------------------------

ExtMail系统加密方式简介

有关ExtMail系统支持的加密方式,格式一直没有很正规的文档描述,这里我们做简单的介绍,以后整理成正式文档。目前支持的密码主要有以下的类型:

CRYPT

老系统的加密方式,密码长度超过8位的话多出的部分是无法使用的,假设密码为12345678和12345678abcdefghijklmn 这2个是完全等效的。

CLEANTEXT及PLAIN

明文密码,没啥好介绍的

MD5及MD5CRYPT

这个是参有salt的MD5加密,是目前emos和extman默认的加密方式,以下是一个例子:$1$QHhXzURU$a66/ExIQab7XNSa9/veEo/ ,该方式特点是$1$开头。即使同一个密码,每次加密完的结果都不一样。增加了保密性。

PLAIN-MD5

这是平常大家习惯见到的32位md5加密串,和php中的md5函数结果完全一致

LDAP-MD5

这种是适合在openLDAP或其他ldap里使用的密码,他的特点是以{MD5}开头,密文部分是base64编码的。因此要特别注意和PLAIN-MD5区分开。

SHA/SHA1

就是传说中的SHA加密。但要注意和SSHA(Salt-SHA)分开。后者是带了salt的方式。

postfix check 可以检查当前postfix的配置是否有问题、文件和目录权限是否正确。

postconf -m查看postfix支持的查询表的类型

postconf -a 检查支持的SASL Server 插件的类型

postconf -A 检查支持的SASL Client 插件的类型

简化postfix的配置文件

postconf -n > /etc/postfix/main.cf.new

mv /etc/postfix/main.cf /etc/postfix/main.cf.old

mv /etc/postfix/main.cf.new /etc/postfix/main.cf

本文出自 “linux学习之旅” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐