您的位置:首页 > 数据库 > MySQL

RHEL 4.1+courier-imap+postfix+mysql+extmail+extman

2009-04-08 09:35 399 查看
配置过程
1.基本软件安装
安装RHEL 4 U1,关闭SE Linux,安装 “系统自带”的软件,包括:
万维网服务器:全部
邮件服务器:全部
MySQL 数据库:全部。
开发包:development tools;kde software development;legacy software delelopment;xsoftware development
下载其它需要的软件:
courier-authlib-0.58.tar.bz2 google.cn
courier-imap-4.0.6.tar.bz2 google.cn
extmail-1.0.3.tar.gz www.extmail.org
extman-0[1][1].2.3.tar.gz
postfix-2.5.0.tar.gz.tar.gz www.postfix.org
MailScanner-4.49.7-1.rpm.tar.gz
fp-linux-ws.rpm
一、软件安装
1.关闭selinux
[root@redhat as4]# vi /etc/selinux/config
SELINUX=disable
[root@redhat as4]# reboot
2. 编译、配置Postfix
先停止sendmail
[root@localhost tmp]# service sendmail stop
[root@localhost tmp]# tar -zxvf postfix-2.5.0.tar.gz
[root@localhost tmp]# cd postfix-2.5.0
[root@localhost tmp]#useradd postfix
[root@localhost tmp]#groupadd postdrop
[root@localhost tmp]# make -f Makefile.init makefiles /
'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DHAS_MYSQL -I/usr/include/mysql -I/usr/include/sasl' /
'AUXLIBS=-L/usr/lib/mysql -L/usr/lib/sasl2 -lmysqlclient -lsasl2 -lz -lm'
[root@localhost tmp]# make
[root@localhost tmp]# make install
执行make install这里会出现很多问题,但postfix已经为我们设置好了默认的答案,直接使用这些答案就可以使postfix正常工作了,所以我们只要直接按回车就可以了。
3. 安装Courier-imap
编译模块courier-authlib,
[root@localhost tmp]# tar –jxvf courier-authlib-0.58.tar.bz2
[root@localhost tmp]# cd courier-authlib-0.58
[root@localhost tmp]# ./configure --prefix=/usr/lib/authlib --without-authpam /
--without-authcustom --without-authpgsql --without-authldap /
--without-authuserdb --without-authpwd --without-authshadow /
--without-authvchkpw --with-authmysql /
--with-authdaemonvar=/usr/lib/authlib/var /
--mandir=/usr/lib/man --without-stdheaderdir /
--sysconfdir=/usr/lib/authlib/etc /
--with-redhat
[root@localhost tmp]# make
[root@localhost tmp]# make install
[root@localhost tmp]# make install-migrate
[root@localhost tmp]# make install-configure
因为改变了courier-authlib的安装位置,所以需要加选项--without-stdheaderdir,在编译imapd的时候需要设定环境变量COURIERAUTHCONFIG,它的值就是完整courierauthconfig的路径,configure通过运行这个命令得到authlib的头文件,库文件的位置。假如没有指定COURIERAUTHCONFIG,或者指定的courierauthconfig的路径是错误的,那么courier-imap将无法找到头文件和库文件。例子:
/usr/lib/authlib/bin/courierauthconfig --ldflags
程序输出-L/usr/lib/authlib/lib/authlib
/usr/lib/authlib/bin/courierauthconfig --cppflags
程序输出-I/usr/lib/authlib/include
编译imapd
[root@localhost tmp]# tar jxvf courier-imap-4.0.6.tar.bz2
[root@localhost tmp]# cd courier-imap-4.0.6
[root@localhost tmp]# COURIERAUTHCONFIG=/usr/lib/authlib/bin/courierauthconfig ./configure --prefix=/usr/lib/imapd /
--silent --without-authpgsql --without-ipv6 /
--with-redhat --with-authmysql /
--mandir=/usr/lib/man --disable-root-check
[root@localhost tmp]# make
[root@localhost tmp]# make install
二、配置系统
1.配置postfix
[root@localhost tmp]# cd /etc/postfix
[root@localhost postfix]# /usr/sbin/postconf -n > main2.cf
[root@localhost postfix]# mv main.cf main.cf.old
[root@localhost postfix]# mv main2.cf main.cf
[root@localhost postfix]# vi main.cf (与以下一致)
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
myhostname = redhat.test.com
mydomain = test.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost
alias_maps = hash:/etc/aliases
home_mailbox = Maildir/
# Add following line in file's finality
#指定postfix如何去检索虚拟别名
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_base = /home/mail
#指定postfix如何去检索虚拟域
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

virtual_mailbox_limit = 102400000
#指定postfix如何去检索邮箱,这里是采用mysql
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 501
#邮件账号uid, 即postfix组id号(即/var/mailbox目录所有者的帐号)
virtual_uid_maps = static:501

virtual_gid_maps = static:501

(这里注意一下,这个uid和gid 要与系统中建立的postfix用户和组一致才可以,不然收不到邮件
#如果没有安装maildrop,则此处为virtual
virtual_transport = virtual
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his disk
space quota, please try again later.
virtual_overquota_bounce = yes
virtual_trash_count=yes
virtual_trash_name=.Trash
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,rejec
t_non_fqdn_hostname,reject_non_fqdn_sender,reject_non_fqdn_recipient, reject_una
uth_destination,reject_unauth_pipelining, reject_invalid_hostname,reject_rbl_cli
ent opm.blitzed.org,reject_rbl_client list.dsbl.org,reject_rbl_client bl.spamcop
.net,reject_rbl_client sbl-xbl.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
[root@localhost tmp]# mv /etc/aliases /etc/aliases.old
[root@localhost tmp]# ln -s /etc/postfix/aliases /etc/aliases
[root@localhost tmp]# echo 'root: admin@example.com'>>/etc/postfix/aliases
[root@localhost tmp]#/usr/bin/newaliases
[root@localhost postfix]# mkdir /home/mail
[root@localhost postfix]# chown -R postfix:postfix /home/mail
2. 配置sasl认证
[root@localhost postfix]# vi /usr/lib/sasl2/smtpd.conf(新建)
pwcheck_method: authdaemond
log_level: 3
mech_list: plain login
authdaemond_path:/usr/lib/authlib/var/socket
3. 配置courier-imap
[root@localhost postfix]#vi /usr/lib/authlib/etc/authlib/authmysqlrc (修改以下所列项目)
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD '501'
MYSQL_GID_FIELD '501'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/home/mail/',homedir)
MYSQL_MAILDIR_FIELD concat('/home/mail/',maildir)
MYSQL_NAME_FIELD name
4. 配置authdaemonrc:
[root@localhost postfix]# vi /usr/lib/authlib/etc/authlib/authdaemonrc (修改以下几点)
authmodulelist="authmysql"
authmodulelistorig="authmysql "
[root@localhost postfix]# vi /usr/lib/imapd/etc/pop3d (修改如下)
POP3DSTART=YES
[root@localhost postfix]# chmod -R 755 /usr/lib/authlib/var/
[root@localhost postfix]# chmod -R 755 /usr/lib/authlib/etc/authlib/
[root@localhost postfix]# cp /usr/lib/imapd/etc/pop3d.dist /usr/lib/imapd/etc/pop3d
[root@localhost postfix]# cp /usr/lib/imapd/etc/pop3d-ssl.dist /usr/lib/imapd/etc/pop3d-ssl
[root@localhost postfix]# cp /usr/lib/imapd/etc/imapd.dist /usr/lib/imapd/etc/imapd
[root@localhost postfix]# cp /usr/lib/imapd/etc/imapd-ssl.dist /usr/lib/imapd/etc/imapd-ssl
5. 安装Extmail
tar zxvf extmail-0.22.tar.gz
[root@localhost postfix]# mv extmail-0.22 /var/www/html/extmail
[root@localhost postfix]# cd /var/www/html/extmail
[root@localhost extmail]# chown -R postfix:postfix cgi
[root@localhost extmail]# cp webmail.cf.default webmail.cf
[root@localhost extmail]# vi webmail.cf
SYS_CONFIG = /var/www/html/extmail/
SYS_LANGDIR = /var/www/html/extmail/lang
SYS_TEMPLDIR = /var/www/html/extmail/html
SYS_USER_LANG = zh_CN
SYS_USER_CHARSET = gb2312
SYS_MAILDIR_BASE = /home/mail
SYS_CRYPT_TYPE = crypt
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail

6. 配置Apache:
[root@localhost extmail]# vi /etc/httpd/conf/httpd.conf
#AddDefaultCharset UTF-8
AddHandler cgi-script .cgi
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/extmail/html
Alias /extmail/cgi/ /var/www/html/extmail/cgi/
Alias /extmail/ /var/www/html/extmail/html/
Alias /extman/cgi/ /var/www/html/extman/cgi/
Alias /extman/ /var/www/html/extman/html/
SuexecUserGroup postfix postfix
ServerName redhat.test.com
ErrorLog logs/mail.example.com-error_log
CustomLog logs/mail.example.com-access_log common
</VirtualHost>
<Directory /var/www/html/extmail/cgi>
Options +ExecCGI
</Directory>
<Directory /var/www/html/extman/cgi>
Options +ExecCGI
</Directory>

7. 安装Extman
[root@localhost extmail]# tar zvxf extman-0.12.tar.gz
[root@localhost extmail]# mv extman-0.12 /var/www/html/extman
[root@localhost extmail]# cd /var/www/html/extman/libs/Ext
[root@localhost Ext]# cp /var/www/html/extmail/libs/Ext/*.pm
[root@localhost Ext]# chown -R postfix:postfix /var/www/html/extman/cgi
[root@localhost Ext]# mkdir /tmp/extman
[root@localhost Ext]# chown postfix:postfix /tmp/extman
使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
[root@localhost Ext]# cd /var/www/html/extman/docs
[root@localhost docs]# mysql -u root -p <extmail.sql
[root@localhost docs]# mysql -u root -p <init.sql
[root@localhost docs]# cp mysql_virtual_* /etc/postfix/
注:将有四个文件被copy到/etc/postfix目录下面。
配置extman:
[root@localhost docs]# vi /var/www/html/extman/webman.cf
SYS_CONFIG = /var/www/html/extman/
SYS_LANGDIR = /var/www/html/extman/lang
SYS_TEMPLDIR = /var/www/html/extman/html
SYS_MAILDIR_BASE = /home/mail
SYS_QUOTA_TYPE = courier

测试http://192.168.0.1/extman 如果不能出现验证,需要安装GD-2.35
http://search.cpan.org/~lds/GD-2.35/

perl Makefile.PL
提示gd装在哪/usr/local/gd2/lib
(选图片支持)

Where is libgd installed? [/usr/lib] /usr/local/gd2

Build JPEG support? [y] y
Build PNG support? [y] y
Build FreeType support? [y] y
Build GIF support? [y] y
Build support for animated GIFs? [y] y
Build XPM support? [y] n

make
make install
错误:cannot find -lpng
ln -vs /usr/local/libpng2/lib/* /usr/lib
错误:cannot find -lfreetype
ln -vs /usr/local/freetype2/lib/* /usr/lib
错误:cannot find -ljpeg
ln -vs /usr/local/jpeg6/lib/* /usr/lib
再重新make clean
perl Makefile.PL (成功)

也可以去掉extman登录校验码:
在 webman.cf 将 SYS_CAPTCHA_ON=0 即可,要重启 Apache

三、启动服务
1. MySQL
[root@localhost postfix]# service mysqld start
2. Postfix
[root@localhost postfix]# /usr/sbin/postfix start
3. Courier-imap
[root@localhost postfix]# /usr/lib/authlib/sbin/authdaemond start
[root@localhost postfix]# /usr/lib/imapd/libexec/pop3d.rc start
[root@localhost postfix]# /usr/lib/imapd/libexec/imapd.rc start
[root@localhost postfix]# vi /etc/rc.local
/usr/sbin/postfix start
/usr/lib/authlib/sbin/authdaemond start
/usr/lib/imapd/libexec/pop3d.rc start
/usr/lib/imapd/libexec/imapd.rc start
四、配置杀毒、过滤SPAM功能
1. 安装f-prot
[root@localhost postfix]# rpm -ivh fp-linux-ws.rpm
2. 启动SpamAssassin
[root@localhost postfix]# service spamassassin start
[root@localhost postfix]# chkconfig spamassassin on
3. 安装、配置MailScanner
[root@localhost postfix]# tar xzf MailScanner-4.49.7-1.rpm.tar.gz
[root@localhost postfix]# cd MailScanner-4.49.7-1
[root@localhost MailScanner-4.49.7-1]# ./install.sh
[root@localhost postfix]# vi /etc/MailScanner/MailScanner.conf
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = f-prot
Always Include SpamAssassin Report = yes
Use SpamAssassin = yes
Required SpamAssassin Score = 4
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
SpamAssassin Install Prefix = /usr/bin
SpamAssassin Local Rules Dir = /etc/MailScanner
[root@localhost postfix]# vi /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks
[root@localhost postfix]# vi /etc/postfix/header_checks
/^Received:/ HOLD
[root@localhost postfix]# chown postfix.postfix /var/spool/MailScanner/incoming
[root@localhost postfix]# chown postfix.postfix /var/spool/MailScanner/quarantine
[root@localhost postfix]# postfix stop
[root@localhost postfix]# service MailScanner start
[root@localhost postfix]# chkconfig MailScanner on
注:MailScanner 会自动启动Postfix。
测试SpamAssassin
发一封邮件带如下内容,接收后,标题应该带有标记:
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
测试f-prot
升级病毒库:
# /usr/local/f-prot/tools/check-updates.pl
访问http://www.webmail.us/testvirus,申请一封邮件寄到自己的邮箱

命令使用:

1.管理邮件队列

显示信件清单: postqueue -p或者mailq
显示信件内容: postcat -q Queue_ID
各别信件postsuper -d Queue_ID
全部删除postsuper -d ALL
扣住信件
postsuper -h Queue_ID
回复postsuper -H Queue_ID
重进排程
postsuper -r Queue_ID

postsuper -r ALL
扫清信件
postqueue -f (全部)
postqueue -s主机名称(个别对象)

参考:
http://blog.chinaunix.net/u1/54725/showart_432881.html

http://small.dropbear.id.au/myscripts/postfixmysql.html

http://www.postfix.org/SASL_README.html

问题:
1、首次打开web页面报这个错误:
Unix::Syslog not found, please install it first! (in cleanup) Undefined subroutine &Ext::Logger::do_closelog called at /var/www/extsuite/extmail/libs/Ext/Logger.pm line 87.
解决方法:
是到http://search.cpan.org搜索Syslog下载一个Unix-Syslog-0.100.tar.gz
tar zxvf Unix-Syslog-0.100.tar.gz
cd Unix-Syslog-0.100
perl Makefile.PL
make
make install
2、extman 默认密码
extmail*123*

原文地址 http://extmail.org/forum/archive/2/0604/1359.html http://extmail.org/forum/archive/2/0604/1359.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: