电子邮件服务器(2)

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

[root@mail ~]# mkdir -pv /var/mailbox

mkdir: created directory `/var/mailbox'

[root@mail ~]# chown -R postfix /var/mailbox

接下来重新配置SMTP 认证,编辑 /usr /lib/sasl2/smtpd.conf ,确保其为以下内容:

pwcheck_method: authdaemond

log_level: 3

mech_list:PLAIN LOGIN

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

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

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

添加如下内容;

virtual_mailbox_base = /var/mailbox

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:2525

virtual_gid_maps = static:2525

virtual_transport = virtual

maildrop_destination_recipient_limit = 1

maildrop_destination_concurrency_limit = 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

使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:

[root@mail ~]# tar -zxvf extman-1.1.tar.gz -C /usr/src/

[root@mail ~]# cd /usr/src/extman-1.1/docs/

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

Enter password:

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

Enter password:

密码为“redhat”

mysql -u root -p 进行验证

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

授予用户extmail访问extmail数据库的权限

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

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

mysql>FLUSH PRIVILEGES; 让设置的内容生效

具体操作:

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

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

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.01 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql>

重启postfix

[root@mail docs]# service postfix restart

配置dovecot

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

增加一行:

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

796 #passdb pam {

897 #userdb passwd {

870 passdb sql {

#path for SQL configuration file, see doc/dovecot-sql-example.conf

args = /etc/dovecot-mysql.conf

}

933 userdb sql {

#path for SQL configuration file, see doc/dovecot-sql-example.conf

args = /etc/dovecot-mysql.conf

}

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

416 home_mailbox = Maildir/

编辑新文件dovecot-mysql.conf

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

添加如下内容:

driver = mysql

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

default_pass_scheme = CRYPT

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

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

启动dovecot

[root@mail ~]# service dovecot start

[root@mail ~]# chkconfig dovecot on

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

1、安装

[root@mail ~]# tar -zxvf extmail-1.2.tar.gz -C /usr/src/

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

[root@mail ~]# cd /usr/src/

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

[root@mail src]# cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf

2、修改主配置文件

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

SYS_USER_LANG = en_US

语言选项,可改作:

SYS_USER_LANG = zh_CN

SYS_MAILDIR_BASE = /home/domains

当前文所设置的用户邮件的存放目录,可改作:

SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = db_user

SYS_MYSQL_PASS = db_pass

修改为:

SYS_MYSQL_USER = extmail

SYS_MYSQL_PASS = extmail

SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket

修改为:

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

apache相关配置

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

编辑apache配置文件

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

231 User postfix

232 Group postfix

在最后添加如下内容:

<VirtualHost 192.168.101.200:80>

ServerName mail.abc.com

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

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

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

</VirtualHost>

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

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

4、依赖关系的解决

extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装

[root@mail ~]# tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/src/

[root@mail ~]# cd /usr/src/Unix-Syslog-1.1/

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

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

启动apache

[root@mail Unix-Syslog-1.1]# service httpd start

[root@mail Unix-Syslog-1.1]# chkconfig httpd on

八、 安装Extman-1.1

1、安装及基本配置

[root@mail ~]# tar -zxvf extman-1.1.tar.gz -C /usr/src/

[root@mail ~]# cd /usr/src/

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

[root@mail ~]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf

[root@mail ~]# vim /var/www/extsuite/extman/webman.cf

SYS_MAILDIR_BASE = /home/domains

用户邮件的存放目录,可改作:

SYS_MAILDIR_BASE = /var/mailbox

修改

SYS_CAPTCHA_ON = 1

SYS_CAPTCHA_ON = 0

修改cgi目录的属主:

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

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

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

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

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

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

[root@mail ~]#

编辑/etc/postfix/main.cf

注释掉165、166行

重启apache服务

测试:

在浏览器中输入http://mail.abc.com/extmail

 

 

你可能感兴趣的:(职场,邮件服务器,休闲)