Linux下mail服务器架构之源码实现postfix邮件基本功能

 Linux下mail服务器架构之

源码实现postfix邮件基本功能

一、安装前的准备工作:

[root@junjie ~]# uname –r    # 查看Linux的环境
2.6.25.19

准备:关闭firewall和SELinux(略)

准备:下载以下软件

Unix-Syslog-1.1.tar.gz
courier-authlib-0.63.1.20111230.tar.bz2
extmail-1.2.tar.gz
extman-1.1.tar.gz
postfix-2.8.2.tar.gz

1.#修改ip地址为192.168.101.210,修改dns指向为192.168.101.210

[root@junjie ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

NETMASK=255.255.255.0
IPADDR=192.168.101.210

[root@junjie ~]# service network restart

[root@junjie ~]# vim /etc/resolv.conf

nameserver 192.168.101.210

2、卸载sendmail,sendmail将占用tcp 25端口,和postfix冲突:

[root@junjie ~]# rpm -e sendmail --nodeps

3、安装以下开发所用到的rpm包组:

Development Libraries
Development Tools

Legacy Software Development

X Software Development

#安装方法: yum groupinstall "packge_group_name"

4.构建本地yum服务器(略)

5.安装配置dns服务器:

[root@junjie ~]# yum install -y bind bind-chroot caching-nameserver

[root@junjie ~]# cd /var/named/chroot/etc/

[root@junjie etc]# cp –p named.caching-nameserver.conf named.conf

[root@junjie etc]# vim named.conf

15         listen-on port 53 { any; };

27         allow-query     { any; };

37         match-clients      { any; };

38         match-destinations { any; };

[root@junjie etc]# vim named.rfc1912.zones

20 zone "junjie.com" IN {

 21         type master;
 22         file "junjie.com.db";
 23         allow-update { none; };
 24 };

37 zone "101.168.192.in-addr.arpa" IN {

 38         type master;
 39         file "192.168.101.db";
 40         allow-update { none; };
 41 };

[root@junjie etc]# cd ../var/named/

[root@junjie named]# cp -p localhost.zone junjie.com.db

[root@junjie named]# vim junjie.com.db

 2 @               IN SOA ns.junjie.com.       root (
 9 @               IN NS           ns.junjie.com.
 10 ns              IN A            192.168.101.210
 11 mail            IN A            192.168.101.210
 12 pop3            IN CNAME        mail
 13 smtp            IN CNAME        mail
 14 @               IN MX 10        mail

[root@junjie named]# cp -p named.local 192.168.101.db

[root@junjie named]# vim 192.168.101.db

 210     IN      PTR     mail.junjie.com.

[root@junjie named]# chkconfig named on

[root@junjie named]# service named start

[root@junjie named]# rndc reload

server reload successful
# 查看dns解析是否正常

[root@junjie named]# nslookup pop3.junjie.com

[root@junjie named]# nslookup mail.junjie.com

[root@junjie named]# dig -t mx junjie.com

[root@junjie named]# nslookup 192.168.101.210

6.修改主机名称,并重新启动系统,重启后挂载光盘

[root@junjie named]# vim /etc/sysconfig/network

HOSTNAME=mail.junjie.com

[root@junjie named]# init 6

[root@mail ~]# mount /dev/cdrom /mnt/cdrom/

7、安装所需的rpm包,这包括以下这些:

#httpd, php, php-mysql, mysql, mysql-server, mysql-devel,

#openssl-devel, dovecot, perl-DBD-MySQL, tcl, tcl-devel, libart_lgpl,

#libart_lgpl-devel, libtool-ltdl, libtool-ltdl-devel, expect

[root@junjie ~]# yum install -y httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect

[root@mail ~]# chkconfig mysqld on
[root@mail ~]# service mysqld start

[root@mail ~]# netstat -tupln |grep mysqld

# 启动mysql数据库,并给mysql的root用户设置密码:

[root@mail ~]# mysqladmin -u root password "123"

[root@mail ~]# mysql -u root -p

mysql> SET PASSWORD FOR root@'localhost'=PASSWORD('redhat');

Query OK, 0 rows affected (0.00 sec)

mysql> SET PASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

#---------------------------------授权本地用户

#SET PASSWORD FOR root@'localhost'=PASSWORD('redhat');

#SET PASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');

#FLUSH PRIVILEGES;

#-------------------------------授权远程用户

#GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';

#FLUSH PRIVILEGES;

8.启动saslauthd服务,并将其加入到自动启动队列:

[root@mail ~]# chkconfig saslauthd on
[root@mail ~]# service saslauthd start

Starting saslauthd:                                        [ OK ]

二、安装配置postfix

[root@mail ~]# groupadd -g 2525 postfix

[root@mail ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix

[root@mail ~]# groupadd -g 2526 postdrop

[root@mail ~]# useradd -g postdrop -u 2526 -s /bin/false -M postdrop

[root@mail ~]# cd /root/mail/
[root@mail mail]# ls
Unix-Syslog-1.1.tar.gz
courier-authlib-0.63.1.20111230.tar.bz2
extmail-1.2.tar.gz
extman-1.1.tar.gz
postfix-2.8.2.tar.gz

[root@mail mail]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/src/

[root@mail postfix-2.8.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto'

[root@mail postfix-2.8.2]# make
[root@mail postfix-2.8.2]# make install
# 按照以下的提示输入相关的路径([]号中的是缺省值,”]”后的是输入值,省略
# 的表示采用默认值)
install_root: [/]

tempdir: [/usr/src/postfix-2.8.2] /tmp

config_directory: [/etc/postfix]

command_directory: [/usr/sbin]

daemon_directory: [/usr/libexec/postfix]

data_directory: [/var/lib/postfix]

html_directory: [no]

mail_owner: [postfix]

mailq_path: [/usr/bin/mailq]

manpage_directory: [/usr/local/man]

newaliases_path: [/usr/bin/newaliases]

…………………
# 生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:
[root@mail postfix-2.8.2]# newaliases
# 查看postfix支持的模块是否有mysql
[root@mail postfix-2.8.2]# postconf –m
mysql
2 .进行一些基本配置,测试启动postfix并进行发信

[root@mail postfix-2.8.2]# cp /etc/postfix/main.cf /etc/postfix/main.cf.bak

[root@mail postfix-2.8.2]# vim /etc/postfix/main.cf

76 myhostname = mail.junjie.com

83 mydomain = junjie.com

99 myorigin = $mydomain

113 inet_interfaces = all

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

163         mail.$mydomain, www.$mydomain, ftp.$mydomain

260 mynetworks = 192.168.101.0/24, 127.0.0.0/8

说明:

myorigin 参数用来指明发件人所在的域名;
mydestination 参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;
myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;
mydomain 参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;
mynetworks 参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问;
inet_interfaces 参数指定postfix系统监听的网络接口;

注意:

1 、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
2 、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;
3 、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;
4 、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一个字符为空格或tab的文本行视为上一行的延续;

[root@mail postfix-2.8.2]# service postfix restart

postfix: unrecognized service

# 制作postfix启动控制文件
# 没有启动文件的启动postfix方法如下:
#/usr/local/postfix/sbin/postfix start

[root@mail postfix-2.8.2]# mkdir /root/abc

[root@mail postfix-2.8.2]# cd /root/abc/

[@mail abc]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./

[root@mail abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id

16333 blocks
[root@mail abc]# ll
[root@mail abc]# ll etc/rc.d/init.d/
total 4

-rwxr-xr-x 1 root root 2404 Apr 1 12:24 postfix

[root@mail abc]# cp etc/rc.d/init.d/postfix /etc/init.d/

[root@mail abc]# ll /etc/init.d/postfix

-rwxr-xr-x 1 root root 2404 Apr 1 12:27 /etc/init.d/postfix

[root@mail abc]# service postfix start

Starting postfix:                                          [ OK ]

[root@mail abc]# service postfix restart

Shutting down postfix:                                     [ OK ]

Starting postfix:                                          [ OK ]

[root@mail abc]# chkconfig --add postfix

[root@mail abc]# chkconfig postfix on 

[root@mail abc]# chkconfig --list postfix

postfix        0:off      1:off      2:on       3:on       4:on       5:on       6:off
# 连接postfix,验正服务启动状况,测试是否可以发信:
[root@mail abc]# telnet mail.junjie.com 25

Trying 192.168.101.210...

Connected to mail.junjie.com (192.168.101.210).

Escape character is '^]'.

220 mail.junjie.com ESMTP Postfix

EHLO mail.junjie.com
250-mail.junjie.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:[email protected]
250 2.1.0 Ok
250 2.1.5 Ok
data  

354 End data with <CR><LF>.<CR><LF>

my mail 1.--0409
.

250 2.0.0 Ok: queued as CF06916DC89

quit
221 2.0.0 Bye

Connection closed by foreign host.

You have new mail in /var/spool/mail/root

#root 收信测试
[root@mail abc]# mail

Mail version 8.1 6/6/93. Type ? for help.

"/var/spool/mail/root": 2 messages 2 new

>N 1 [email protected]   Sun Apr 1 12:30 41/1392 "Logwatch for mail.junjie.com"
 N 2 [email protected]           Mon Apr 9 16:53 13/446 
& 2
Message 2:

From [email protected] Mon Apr 9 16:53:29 2012

X-Original-To: [email protected]

Delivered-To: [email protected]

Date: Mon, 9 Apr 2012 16:52:15 +0800 (CST)
 
my mail 1.--0409
 
& q

Saved 1 message in mbox

Held 1 message in /var/spool/mail/root

#[root@mail abc]# ll /etc/aliases.db
# 若不存在/etc/aliases.db使用newaliases生成别名二进制文件

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

[root@mail ~]# yum list all |grep sasl

# 使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为
# 以下结果,则是支持的:
[root@mail ~]# postconf -a
cyrus
dovecot
# 添加以下内容:
[root@mail ~]# vim /etc/postfix/main.cf

652 ############################CYRUS-SASL#####################    #######

653 broken_sasl_auth_clients = yes

654 smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_    authenticated,reject_invalid_hostname,reject_non_fqdn_hostn    ame,reject_unknown_sender_domain,reject_non_fqdn_sender,rej    ect_non_fqdn_recipient,reject_unknown_recipient_domain,reje    ct_unauth_pipelining,reject_unauth_destination

655 smtpd_sasl_auth_enable = yes

656 smtpd_sasl_local_domain = $myhostname

657 smtpd_sasl_security_options = noanonymous

658 smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Ve    rsion not Available!

# 添加如下内容:
[root@mail ~]# vim /usr/lib/sasl2/smtpd.conf

pwcheck_method: saslauthd

mech_list: PLAIN LOGIN

#启动 sasl服务,让postfix重新加载配置文件

[root@mail ~]# chkconfig saslauthd on
[root@mail ~]# service saslauthd start

Starting saslauthd:                                        [ OK ]

[root@mail ~]# service postfix restart

Shutting down postfix:                                     [ OK ]

Starting postfix:                                          [ OK ]

# 确保输出以下类似两行,说明支持认证

[root@mail ~]# telnet mail.junjie.com 25

Trying 192.168.101.210...

Connected to mail.junjie.com (192.168.101.210).

Escape character is '^]'.

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

EHLO mail.junjie.com

250-mail.junjie.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

四、安装Courier authentication library

[root@mail ~]# cd /root/mail/
[root@mail mail]# ls
Unix-Syslog-1.1.tar.gz
courier-authlib-0.63.1.20111230.tar.bz2
extmail-1.2.tar.gz
extman-1.1.tar.gz
postfix-2.8.2.tar.gz

[root@mail mail]# tar -jxvf courier-authlib-0.63.1.20111230.tar.bz2 -C /usr/src/

[root@mail mail]# cd /usr/src/courier-authlib-0.63.1.20111230/

[root@mail courier-authlib-0.63.1.20111230]# ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/include

[root@mail courier-authlib-0.63.1.20111230]# make

[root@mail courier-authlib-0.63.1.20111230]# make install

[root@mail courier-authlib-0.63.1.20111230]# cd /usr/local/courier-authlib/var/spool/

[root@mail spool]# ll
total 4

drwxr-x--- 2 daemon daemon 4096 Apr 9 17:38 authdaemon

[root@mail spool]# chmod 755 authdaemon/

[root@mail spool]# cp /etc/authdaemonrc.dist /etc/authdaemonrc

[root@mail spool]# cp /etc/authmysqlrc.dist /etc/authmysqlrc

# 修改/etc/authdaemonrc 文件
[root@mail spool]# vim /etc/authdaemonrc

27 authmodulelist="authmysql"

34 authmodulelistorig="authmysql"

53 daemons=10
# 编辑/etc/authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的
#UID 和GID。

[root@mail spool]# vim /etc/authmysqlrc

MYSQL_SERVER localhost

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

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 '2525'
MYSQL_GID_FIELD '2525'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)

[root@mail ~]# cd /usr/src/courier-authlib-0.63.1.20111230/          

[root@mail courier-authlib-0.63.1.20111230]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib

[root@mail courier-authlib-0.63.1.20111230]# cd

[root@mail ~]# chmod 755 /etc/init.d/courier-authlib

[root@mail ~]# chkconfig --add courier-authlib

[root@mail ~]# chkconfig --level 2345 courier-authlib on

[root@mail ~]# chkconfig --list courier-authlib

courier-authlib 0:off      1:off      2:on       3:on       4:on       5:on       6:off

[root@mail ~]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf

[root@mail ~]# ldconfig -v |grep cour
# 启动服务

[root@mail ~]# service courier-authlib start

Starting Courier authentication services: authdaemond

# 新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
[root@mail ~]# mkdir -pv /var/mailbox
[root@mail ~]# chown -R postfix /var/mailbox

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

# 确保其为以下内容

[root@mail ~]# vim /usr/lib/sasl2/smtpd.conf

 1 pwcheck_method: authdaemond
 2 log_level: 3
 3 mech_list:PLAIN LOGIN

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

五、让postfix支持虚拟域和虚拟用户

1 、编辑/etc/postfix/main.cf,添加如下内容:
[root@mail ~]# vim /etc/postfix/main.cf

659 ########################Virtual Mailbox Settings########################

660 virtual_mailbox_base = /var/mailbox

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

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

663 virtual_alias_domains =

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

665 virtual_uid_maps = static:2525

666 virtual_gid_maps = static:2525

667 virtual_transport = virtual

668 maildrop_destination_recipient_limit = 1

669 maildrop_destination_concurrency_limit = 1

670 ##########################QUOTA Settings########################

671 message_size_limit = 14336000

672 virtual_mailbox_limit = 20971520

673 virtual_create_maildirsize = yes

674 virtual_mailbox_extended = yes

675 virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit    _maps.cf

676 virtual_mailbox_limit_override = yes

677 virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his     diskspace quota, please Tidy your mailbox and try again later.

678 virtual_overquota_bounce = yes

2 、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
[root@mail ~]# cd /root/mail/
[root@mail mail]# ls
Unix-Syslog-1.1.tar.gz                  
extman-1.1.tar.gz
courier-authlib-0.63.1.20111230.tar.bz2 
postfix-2.8.2.tar.gz
extmail-1.2.tar.gz

[root@mail mail]# tar -zxvf extman-1.1.tar.gz

[root@mail mail]# cd extman-1.1/docs/
[root@mail docs]# ls

[root@mail docs]# mysql -u root -p <extmail.sql

Enter password:

[root@mail docs]# mysql -u root -p <init.sql

Enter password:
[root@mail docs]# mysql -u root -p

mysql> show databases;

+--------------------+
| Database           |
+--------------------+

| information_schema |

| extmail             |
| mysql              |
| test               |
+--------------------+

4 rows in set (0.01 sec)

[root@mail docs]# cp mysql* /etc/postfix/

3 、授予用户extmail访问extmail数据库的权限
[root@mail docs]# mysql -u root -p

mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';

Query OK, 0 rows affected (0.00 sec)

 

mysql> GRANT all privileges on extmail.* TO [email protected] IDENTIFIED BY 'extmail';

Query OK, 0 rows affected (0.00 sec)

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

[root@mail docs]# service postfix restart

Shutting down postfix:                                     [ OK ]

Starting postfix:                                          [ OK ]

说明:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。

[root@mail docs]# vim /etc/postfix/main.cf

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

163 #       mail.$mydomain, www.$mydomain, ftp.$mydomain

六、配置dovecot

# 修改,增加,把userdb的其他相关禁用
[root@mail ~]# vim /etc/dovecot.conf

205    mail_location = maildir:/var/mailbox/%d/%n/Maildir

795 # passdb pam {
828  # }
869   passdb sql {
871     args = /etc/dovecot-mysql.conf
872   }
930   userdb sql {
932     args = /etc/dovecot-mysql.conf
933   }
# 打开一行,#postfix的配置文件也要该
[root@mail ~]# vim /etc/postfix/main.cf

415 home_mailbox = Maildir/

# 手动产生/etc/dovecot-mysql.conf文件:

[root@mail ~]# vim /etc/dovecot-mysql.conf

 1 ver = mysql

 2 connect = host=localhost dbname=extmail user=extmail password=extmail

 3 default_pass_scheme = CRYPT

 4 password_query = SELECT username AS user,password AS password FROM mailbox     WHERE username = '%u'

 5 user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbo    x WHERE username = '%u'

# 接下来启动dovecot服务
[root@mail ~]# chkconfig dovecot on
[root@mail ~]# service dovecot start

Starting Dovecot Imap:                                     [ OK ]

七、安装Extmail-1.2 (先安装httpd)

1 、安装
[root@mail ~]# cd /root/mail/
[root@mail mail]# ls

[root@mail mail]# mkdir -pv /var/www/extsuite

mkdir: created directory `/var/www/extsuite'

[root@mail mail]# tar -zxvf extmail-1.2.tar.gz -C /var/www/extsuite/

[root@mail mail]# tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite/

[root@mail mail]# cd /var/www/extsuite/
[root@mail extsuite]# ll

[root@mail extsuite]# mv extmail-1.2/ extmail    

[root@mail extsuite]# mv extman-1.1/ extman

[root@mail extsuite]# ll
[root@mail extsuite]# cd extmail/

[root@mail extmail]# cp webmail.cf.default webmail.cf

2 、修改主配置文件

[root@mail extmail]# vim /var/www/extsuite/extmail/webmail.cf

77 SYS_USER_LANG = zh_CN
127 SYS_MAILDIR_BASE = /var/mailbox
139 SYS_MYSQL_USER = extmail
140 SYS_MYSQL_PASS = extmail

197 SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

3 、apache相关配置

由于extmail要进行本地邮件的投递操作,故必须将运行apache服务器用户的身份修改为您的邮件投递代理的用户;本例中打开了apache服务器的suexec功能,故使用以下方法来实现虚拟主机运行身份的指定。此例中的MDA为postfix自带,因此将指定为postfix用户:

[root@mail ~]# vim /etc/httpd/conf/httpd.conf

231 User postfix
232 Group postfix

992 <VirtualHost 192.168.101.210:80>

993 ServerName mail.junjie.com

994 DocumentRoot /var/www/extsuite/extmail/html/

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

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

997 </VirtualHost>

修改 cgi执行文件属主为apache运行身份用户:

[root@mail ~]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

4 、依赖关系的解决:extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
[root@mail ~]# cd /root/mail/

[root@mail mail]# tar -zxvf Unix-Syslog-1.1.tar.gz

[root@mail mail]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# ls

[root@mail Unix-Syslog-1.1]# perl Makefile.PL

[root@mail Unix-Syslog-1.1]# make

[root@mail Unix-Syslog-1.1]# make install

5 、启动apache服务
[root@mail ~]# chkconfig httpd on
[root@mail ~]# service httpd start

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using mail.junjie.com for ServerName                       [ OK ]

 

八、安装Extman

1 、安装及基本配置

[root@mail Unix-Syslog-1.1]# cd /var/www/extsuite/extman

[root@mail extman]# ls

修改配置文件以符合本例的需要:

[root@mail extman]# cp webman.cf.default webman.cf        

[root@mail extman]# vim webman.cf

12 SYS_MAILDIR_BASE = /var/mailbox

21 SYS_CAPTCHA_ON = 0

修改cgi目录的属主:

[root@mail extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/

在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:

[root@mail extman]# vim /etc/httpd/conf/httpd.conf

992 <VirtualHost 192.168.101.210:80>

993 ServerName mail.junjie.com

994 DocumentRoot /var/www/extsuite/extmail/html/

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

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

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

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

999 </VirtualHost>

创建其运行时所需的临时目录,并修改其相应的权限:

[root@mail extman]# mkdir -pv /tmp/extman

mkdir: created directory `/tmp/extman'

[root@mail extman]# chown postfix.postfix /tmp/extman

好了,到此为止,重新启动apache服务器后,您的Webmail和Extman已经可以使用了,可以在浏览器中输入指定的虚拟主机的名称进行访问,如下:

[root@mail extman]# service httpd restart

Stopping httpd:                                            [ OK ]

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using mail.junjie.com for ServerName

                                                           [ OK ]

说明:

(1) 如果您安装后无法正常显示校验码,安装perl-GD模块会解决这个问题。如果想简单,您可以到以下地址下载适合您的平台的rpm包,安装即可: http://dries.ulyssis.org/rpm/packages/perl-GD/info.html
(2) extman-1.1 自带了图形化显示日志的功能;此功能需要rrdtool的支持,您需要安装此些模块才可能正常显示图形日志。

九、测试

选择管理即可登入extman进行后台管理了。默认管理帐号为:[email protected] 密码为:extmail*123*

#选择管理即可登入extman进行后台管理了。默认管理帐号为:[email protected] 密码为:extmail*123*

# 新建域Junjie.com

# 用户注册[email protected]

#用户[email protected] 登录发信

# 用户[email protected]发信给 [email protected] 自己

#用户[email protected] 收信

# 注册qq.com域

##用户[email protected]注册

[email protected] 收信成功,附件也能接受

# 查看日志信息如下:
[root@mail ~]# tail -f /var/log/maillog

Apr 9 20:42:56 mail extmail[15058]: user=<[email protected]>, client=192.168.101.1, module=login, status=loginok

Apr 9 20:44:15 mail postfix/smtpd[15067]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

Apr 9 20:44:15 mail postfix/smtpd[15067]: connect from localhost.localdomain[127.0.0.1]

Apr 9 20:44:15 mail postfix/smtpd[15067]: C0F7E16DF4C: client=localhost.localdomain[127.0.0.1]

Apr 9 20:44:15 mail postfix/cleanup[15073]: C0F7E16DF4C: message-id=<[email protected]>

Apr 9 20:44:15 mail postfix/qmgr[14514]: C0F7E16DF4C: from=<[email protected]>, size=659, nrcpt=1 (queue active)

Apr 9 20:44:15 mail postfix/smtpd[15067]: disconnect from localhost.localdomain[127.0.0.1]

Apr 9 20:44:15 mail postfix/virtual[15075]: C0F7E16DF4C: to=<[email protected]>, relay=virtual, delay=0.29, delays=0.17/0.08/0/0.04, dsn=2.0.0, status=sent (delivered to maildir)

Apr 9 20:44:15 mail postfix/qmgr[14514]: C0F7E16DF4C: removed

Apr 9 20:51:35 mail extmail[15177]: user=<[email protected]>, client=192.168.101.1, module=login, status=loginok

Apr 9 20:53:59 mail postfix/smtpd[15190]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

Apr 9 20:53:59 mail postfix/smtpd[15190]: connect from localhost.localdomain[127.0.0.1]

Apr 9 20:54:00 mail postfix/smtpd[15190]: 0AB0F16DF71: client=localhost.localdomain[127.0.0.1]

Apr 9 20:54:00 mail postfix/cleanup[15196]: 0AB0F16DF71: message-id=<[email protected]>

Apr 9 20:54:01 mail postfix/qmgr[14514]: 0AB0F16DF71: from=<[email protected]>, size=4801480, nrcpt=1 (queue active)

Apr 9 20:54:01 mail postfix/smtpd[15190]: disconnect from localhost.localdomain[127.0.0.1]

Apr 9 20:54:01 mail postfix/virtual[15199]: 0AB0F16DF71: to=<[email protected]>, relay=virtual, delay=1.4, delays=1.2/0.05/0/0.21, dsn=2.0.0, status=sent (delivered to maildir)

Apr 9 20:54:01 mail postfix/qmgr[14514]: 0AB0F16DF71: removed

 

--xjzhujunjie

--2012/04/09—21:25

你可能感兴趣的:(架构,服务器,postfix,电子邮件,linux系统)