邮件服务器配置+网页邮件收发

2023-05-16

    在 之前 的 一 篇 的 博客 写 了 一 些 关 于 邮件 服务器 的 简单 的 配置, 这 篇 添加 了 在 网页 上 的 邮件 的 收发 和 用户 认证 等 相关 的 内容。
好 了, 不 多 说 了, 开 始 配置 吧!
一、安装前的准备工作
    在安装前要准备哪些工作呢?为了实现邮件在浏览器和用户认证等相关功能我们需要做以下的工作:
 
1、安装以下开发所用到的rpm包组:
Development Libraries
Development Tools

方法:
InBlock.gif# yum groupinstall "packge_group_name"

   因为邮件服务依赖于DNS服务,请事先确信您的DNS服务已经为邮件应用配置完成。
   如果没有安装在这里要先安装DNS服务,安装的方法:
   安装DNS服务器
InBlock.gif# yum -y install bind    
InBlock.gif# yum -y install caching-nameserver
   编辑主配置文件:
InBlock.gif# vim /etc/named.conf    
InBlock.gifoptions {    
InBlock.gif    directory "/var/named";    
InBlock.gif};    
InBlock.gifzone "." IN {    
InBlock.gif    type hint;    
InBlock.gif    file "named.ca";    
InBlock.gif};    
InBlock.gifzone "localhost" IN {    
InBlock.gif    type master;    
InBlock.gif    file "localhost.zone";    
InBlock.gif};    
InBlock.gifzone "0.0.127.in-addr.arpa" IN {    
InBlock.gif    type master;    
InBlock.gif    file "named.local";    
InBlock.gif};    
InBlock.gifzone "magedu.com" IN {    
InBlock.gif    type master;    
InBlock.gif    file "magedu.com.zone";    
InBlock.gif};    
InBlock.gifzone "16.172.in-addr.arpa" IN {    
InBlock.gif    type master;    
InBlock.gif    file "172.16.zone";    
InBlock.gif};
编辑正向解析区域:
InBlock.gif# cd /var/named    
InBlock.gif# vim magedu.com.zone    
InBlock.gif
InBlock.gif$TTL 600    
InBlock.gif@    IN    SOA    ns.magedu.com.    admin@magedu.com. (    
InBlock.gif                2012032901    
InBlock.gif                2H    
InBlock.gif                20M    
InBlock.gif                7D    
InBlock.gif                1D )    
InBlock.gif        IN    NS    ns.magedu.com.    
InBlock.gif        IN    MX        10        mail.magedu.com.    
InBlock.gifns        IN        A    172.16.35.1    
InBlock.gif
InBlock.gifmail        IN    A    172.16.35.1    
InBlock.gifwww        IN    CNAME    mail    
InBlock.gifpop3        IN    CNAME    mail    
InBlock.gifimap        IN    CNAME    mail        
编辑反向解析区域:
InBlock.gif# cp magedu.com.zone 172.16.zone    
InBlock.gif# vim 172.16.zone    
InBlock.gif
InBlock.gif$TTL 600    
InBlock.gif@    IN    SOA    ns.magedu.com.    admin@magedu.com. (    
InBlock.gif                2012032901    
InBlock.gif                2H    
InBlock.gif                20M    
InBlock.gif                7D    
InBlock.gif                1D )    
InBlock.gif        IN    NS    ns.magedu.com.    
InBlock.gif1.35        IN        PTR    ns.magedu.com.    
InBlock.gif1.35        IN    PTR    mail.magedu.com.
到这时DNS服务器完成。
启动DNS服务:
InBlock.gif# service named configtest         //启动之前先测试一下
InBlock.gif# service named start

命令来测试一下是否能解析:
InBlock.gif#dig -t MX magedu.com

1、安装所需的rpm包,这包括以下这些:
httpd, 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
方法:
InBlock.gif# yum install rmp_NAME -y
注:“rmp_NAME”是上面所提到的rpm包

2、关闭sendmail,并将它的随系统自动启动功能关闭,因为我们要安装一个邮件服务器就要把系统中自带的关闭掉:
InBlock.gif# service sendmail stop
InBlock.gif# chkconfig sendmail off
这些安装前的准备工作做完之后要启动动所要依赖的服务了。

二、启动依赖的服务:

1、启动mysql数据库,并给mysql的root用户设置密码:
InBlock.gif# service mysqld start
InBlock.gif# chkconfig mysqld on
InBlock.gif# mysqladmin -uroot password 'your_password'

2、启动saslauthd服务,并将其加入到自动启动队列:
InBlock.gif# service saslauthd start
InBlock.gif# chkconfig saslauthd on
三、安装配置postfix  
 下载地址:http://www.postfix.org/
1、在安装之前要先为邮件服务创建用户:
InBlock.gif# groupadd -g 2525 postfix
InBlock.gif# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
InBlock.gif# groupadd -g 2526 postdrop
InBlock.gif# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
2、用户创建完成后就开始真正的编译安装postfix
InBlock.gif# tar zxvf postfix-2.9.1.tar.gz
InBlock.gif# cd postfix-2.9.1
InBlock.gif# 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'
InBlock.gif# make
InBlock.gif# make install
在安装过程会有一些安装的提示,按照以下的提示输入相关的路径([]号中的是缺省值,”]”后的是输入值,省略的表示采用默认值)
InBlock.gifinstall_root: [/] /
InBlock.gif    tempdir: [/root/postfix-2.9.1] /tmp/postfix
InBlock.gif    config_directory: [/etc/postfix] /etc/postfix
InBlock.gif    daemon_directory: [/usr/libexec/postfix]    
InBlock.gif    command_directory: [/usr/sbin]    
InBlock.gif    queue_directory: [/var/spool/postfix]
InBlock.gif    sendmail_path: [/usr/sbin/sendmail]
InBlock.gif    newaliases_path: [/usr/bin/newaliases]
InBlock.gif    mailq_path: [/usr/bin/mailq]
InBlock.gif    mail_owner: [postfix]
InBlock.gif    setgid_group: [postdrop]        
InBlock.gif        html_directory: [no]/var/www/html/postfix    
InBlock.gif        manpages: [/usr/local/man]
InBlock.gif        readme_directory: [no]
这些路径可由自己自由定义。
这样postfix 就编译完成了,为了服务启动方便下面给服务提供一个SysV服务
四、为postfix提供SysV服务脚本/etc/rc.d/init.d/postfix
InBlock.gif#!/bin/bash
InBlock.gif#
InBlock.gif# postfix            Postfix Mail Transfer Agent
InBlock.gif#
InBlock.gif# chkconfig: 2345 80 30
InBlock.gif# description: Postfix is a Mail Transport Agent, which is the program \
InBlock.gif#                            that moves mail from one machine to another.
InBlock.gif# processname: master
InBlock.gif# pidfile: /var/spool/postfix/pid/master.pid
InBlock.gif# config: /etc/postfix/main.cf
InBlock.gif# config: /etc/postfix/master.cf
InBlock.gif
InBlock.gif# Source function library.
InBlock.gif. /etc/rc.d/init.d/functions
InBlock.gif
InBlock.gif# Source networking configuration.
InBlock.gif. /etc/sysconfig/network
InBlock.gif
InBlock.gif# Check that networking is up.
InBlock.gif[ $NETWORKING = "no" ] && exit 3
InBlock.gif
InBlock.gif[ -x /usr/sbin/postfix ] || exit 4
InBlock.gif[ -d /etc/postfix ] || exit 5
InBlock.gif[ -d /var/spool/postfix ] || exit 6
InBlock.gif
InBlock.gifRETVAL=0
InBlock.gifprog= "postfix"
InBlock.gif
InBlock.gifstart() {
InBlock.gif  # Start daemons.
InBlock.gif  echo -n $ "Starting postfix: "
InBlock.gif                /usr/bin/newaliases >/dev/ null 2>&1
InBlock.gif  /usr/sbin/postfix start 2>/dev/ null 1>&2 && success || failure $ "$prog start"
InBlock.gif  RETVAL=$?
InBlock.gif  [ $RETVAL -eq 0 ] && touch /var/ lock/subsys/postfix
InBlock.gif                echo
InBlock.gif   return $RETVAL
InBlock.gif}
InBlock.gif
InBlock.gifstop() {
InBlock.gif    # Stop daemons.
InBlock.gif  echo -n $ "Shutting down postfix: "
InBlock.gif  /usr/sbin/postfix stop 2>/dev/ null 1>&2 && success || failure $ "$prog stop"
InBlock.gif  RETVAL=$?
InBlock.gif  [ $RETVAL -eq 0 ] && rm -f /var/ lock/subsys/postfix
InBlock.gif  echo
InBlock.gif   return $RETVAL
InBlock.gif}
InBlock.gif
InBlock.gifreload() {
InBlock.gif  echo -n $ "Reloading postfix: "
InBlock.gif  /usr/sbin/postfix reload 2>/dev/ null 1>&2 && success || failure $ "$prog reload"
InBlock.gif  RETVAL=$?
InBlock.gif  echo
InBlock.gif   return $RETVAL
InBlock.gif}
InBlock.gif
InBlock.gifabort() {
InBlock.gif  /usr/sbin/postfix abort 2>/dev/ null 1>&2 && success || failure $ "$prog abort"
InBlock.gif   return $?
InBlock.gif}
InBlock.gif
InBlock.gifflush() {
InBlock.gif  /usr/sbin/postfix flush 2>/dev/ null 1>&2 && success || failure $ "$prog flush"
InBlock.gif   return $?
InBlock.gif}
InBlock.gif
InBlock.gifcheck() {
InBlock.gif  /usr/sbin/postfix check 2>/dev/ null 1>&2 && success || failure $ "$prog check"
InBlock.gif   return $?
InBlock.gif}
InBlock.gif
InBlock.gifrestart() {
InBlock.gif  stop
InBlock.gif  start
InBlock.gif}
InBlock.gif
InBlock.gif# See how we were called.
InBlock.gif case "$1" in
InBlock.gif    start)
InBlock.gif  start
InBlock.gif  ;;
InBlock.gif    stop)
InBlock.gif  stop
InBlock.gif  ;;
InBlock.gif    restart)
InBlock.gif  stop
InBlock.gif  start
InBlock.gif  ;;
InBlock.gif    reload)
InBlock.gif  reload
InBlock.gif  ;;
InBlock.gif    abort)
InBlock.gif  abort
InBlock.gif  ;;
InBlock.gif    flush)
InBlock.gif  flush
InBlock.gif  ;;
InBlock.gif    check)
InBlock.gif  check
InBlock.gif  ;;
InBlock.gif    status)
InBlock.gif      status master
InBlock.gif  ;;
InBlock.gif    condrestart)
InBlock.gif  [ -f /var/ lock/subsys/postfix ] && restart || :
InBlock.gif  ;;
InBlock.gif    *)
InBlock.gif  echo $ "Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
InBlock.gif  exit 1
InBlock.gifesac
InBlock.gif
InBlock.gifexit $?
为此脚本赋予执行权限:
InBlock.gif# chmod +x /etc/rc.d/init.d/postfix
将postfix服务添加至服务列表:
InBlock.gif# chkconfig --add postfix

设置其开机自动启动:
InBlock.gif# chkconfig postfix on


使用此脚本启动服务,以测试其能否正常执行:
InBlock.gif# service postfix start

此时可使用本地用户测试邮件收发了。
在测试之前要做一些配置,测试启动postfix并进行发信
InBlock.gif# vim /etc/postfix/main.cf
InBlock.gif修改以下几项为您需要的配置
InBlock.gifmyhostname = mail.magedu.com
InBlock.gifmyorigin = magedu.com
InBlock.gifmydomain = magedu.com
InBlock.gifmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
InBlock.gifmynetworks = 192.168.1.0/24, 127.0.0.0/8  ###这个可以根据你自己的ip地址做相应的调整。

说明:
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的文本行视为上一行的延续;
五、实现postfix基于客户端的访问控制
1、基于客户端的访问控制概览

postfix内置了多种反垃圾邮件的机制,其中就包括“客户端”发送邮件限制。客户端判别机制可以设定一系列客户信息的判别条件:
smtpd_client_restrictions
smtpd_data_restrictions
smtpd_helo_restrictions
smtpd_recipient_restrictions
smtpd_sender_restrictions

上面的每一项参数分别用于检查SMTP会话过程中的特定阶段,即客户端提供相应信息的阶段,如当客户端发起连接请求时,postfix就可以根据配置文件中定义的smtpd_client_restrictions参数来判别此客户端IP的访问权限。相应地,smtpd_helo_restrictions则用于根据用户的helo信息判别客户端的访问能力等等。

如果DATA命令之前的所有内容都被接受,客户端接着就可以开始传送邮件内容了。邮件内容通常由两部分组成,前半部分是标题(header),其可以由header_check过滤,后半部分是邮件正文(body),其可以由check_body过滤。这两项实现的是邮件“内容检查”。

postfix的默认配置如下:
smtpd_client_restrictions =
smtpd_data_restrictions =
smtpd_end_of_data_restrictions =
smtpd_etrn_restrictions =
smtpd_helo_restrictions =
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
smtpd_sender_restrictions =

这限制了只有mynetworks参数中定义的本地网络中的客户端才能通过postfix转发邮件,其它客户端则不被允许,从而关闭了开放式中继(open relay)的功能。

Postfix有多个内置的限制条件,如上面的permit_mynetworks和reject_unauth_destination,但管理员也可以使用访问表(access map)来自定义限制条件。自定义访问表的条件通常使用check_client_access, check_helo_access, check_sender_access, check_recipient_access进行,它们后面通常跟上type:mapname格式的访问表类型和名称。其中,check_sender_access和check_recipient_access用来检查客户端提供的邮件地址,因此,其访问表中可以使用完整的邮件地址,如admin@magedu.com;也可以只使用域名,如magedu.com;还可以只有用户名的部分,如marion@。

2、实现示例1

这里以禁止172.16.100.200这台主机通过工作在172.16.100.1上的postfix服务发送邮件为例演示说明其实现过程。访问表使用hash的格式。

(1)首先,编辑/etc/postfix/access文件,以之做为客户端检查的控制文件,在里面定义如下一行:
172.16.100.200 REJECT

(2)将此文件转换为hash格式
# postmap /etc/postfix/access

(3)配置postfix使用此文件对客户端进行检查
编辑/etc/postfix/main.cf文件,添加如下参数:
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access

(4)让postfix重新载入配置文件即可进行发信控制的效果测试了。

3、实现示例2

这里以禁止通过本服务器向microsoft.com域发送邮件为例演示其实现过程。访问表使用hash的格式。
(1)首先,建立/etc/postfix/denydstdomains文件(文件名任取),在里面定义如下一行:
microsoft.com REJECT

(2)将此文件转换为hash格式
# postmap /etc/postfix/denydstdomains

(3)配置postfix使用此文件对客户端进行检查
编辑/etc/postfix/main.cf文件,添加如下参数:
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/denydstdomains, permit_mynetworks, reject_unauth_destination

(4)让postfix重新载入配置文件即可进行发信控制的效果测试了。

4、检查表格式的说明

hash类的检查表都使用类似如下的格式:
pattern action

检查表文件中,空白行、仅包含空白字符的行和以#开头的行都会被忽略。以空白字符开头后跟其它非空白字符的行会被认为是前一行的延续,是一行的组成部分。

(1)关于pattern
其pattern通常有两类地址:邮件地址和主机名称/地址。

邮件地址的pattern格式如下:
user@domain 用于匹配指定邮件地址;
domain.tld 用于匹配以此域名作为邮件地址中的域名部分的所有邮件地址;
user@ 用于匹配以此作为邮件地址中的用户名部分的所有邮件地址;

主机名称/地址的pattern格式如下:
domain.tld 用于匹配指定域及其子域内的所有主机;
.domain.tld 用于匹配指定域的子域内的所有主机;
net.work.addr.ess
net.work.addr
net.work
net 用于匹配特定的IP地址或网络内的所有主机;
network/mask CIDR格式,匹配指定网络内的所有主机;

(2)关于action

接受类的动作:
OK 接受其pattern匹配的邮件地址或主机名称/地址;
全部由数字组成的action 隐式表示OK;

拒绝类的动作(部分):
4NN text
5NN text
其中4NN类表示过一会儿重试;5NN类表示严重错误,将停止重试邮件发送;421和521对于postfix来说有特殊意义,尽量不要自定义这两个代码;
REJECT optional text... 拒绝;text为可选信息;
DEFER optional text... 拒绝;text为可选信息;

六、为postfix开启基于cyrus-sasl的认证功能
使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:
InBlock.gif# postconf    -a
InBlock.gifcyrus
InBlock.gifdovecot
编译配置postfix文件
InBlock.gif#vim /etc/postfix/main.cf
InBlock.gif添加以下内容:
InBlock.gif############################CYRUS-SASL############################
InBlock.gifbroken_sasl_auth_clients = yes
InBlock.gifsmtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
InBlock.gifsmtpd_sasl_auth_enable = yes
InBlock.gifsmtpd_sasl_local_domain = $myhostname
InBlock.gifsmtpd_sasl_security_options = noanonymous
InBlock.gifsmtpd_sasl_application_name = smtpd
InBlock.gifsmtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!

InBlock.gif# vim /usr/lib/sasl2/smtpd.conf
InBlock.gif添加如下内容:
InBlock.gifpwcheck_method: saslauthd
InBlock.gifmech_list: PLAIN LOGIN
好了,配置文件编辑完成 
让postfix重新加载配置文件
InBlock.gif# postfix restart

  下面来连接一下以验证一下认证是否成功启动:
InBlock.gif# telnet localhost 25
InBlock.gifTrying 127.0.0.1...
InBlock.gifConnected to localhost.localdomain (127.0.0.1).
InBlock.gifEscape character is '^]'.
InBlock.gif220 Welcome to our mail.magedu.com ESMTP,Warning: Version not Available!
InBlock.gifehlo mail.magedu.com
InBlock.gif250-mail.magedu.com
InBlock.gif250-PIPELINING
InBlock.gif250-SIZE 10240000
InBlock.gif250-VRFY
InBlock.gif250-ETRN
InBlock.gif250-AUTH PLAIN LOGIN
InBlock.gif250-AUTH=PLAIN LOGIN                             (请确保您的输出以类似两行) 出现这两说明邮件服务器已支持认证了。
InBlock.gif250-ENHANCEDSTATUSCODES
InBlock.gif250-8BITMIME
InBlock.gif250 DSN
七、安装Courier authentication library
1、courier简介

courier-authlib是Courier组件中的认证库,它是courier组件中一个独立的子项目,用于为Courier的其它组件提供认证服务。其认证功能通常包括验正登录时的帐号和密码、获取一个帐号相关的家目录或邮件目录等信息、改变帐号的密码等。而其认证的实现方式也包括基于PAM通过/etc/passwd和/etc/shadow进行认证,基于GDBM或DB进行认证,基于LDAP/MySQL/PostgreSQL进行认证等。因此,courier-authlib也常用来与courier之外的其它邮件组件(如postfix)整合为其提供认证服务。
下载地址:http://www.courier-mta.org/
2、安装

接下来开始编译安装
InBlock.gif# tar jxvf courier-authlib-0.62.4.tar.bz2
InBlock.gif# cd courier-authlib-0.62.4
InBlock.gif#./configure \
InBlock.gif        --prefix=/usr/local/courier-authlib \
InBlock.gif        --sysconfdir=/etc \
InBlock.gif        --without-authpam \
InBlock.gif        --without-authshadow \
InBlock.gif        --without-authvchkpw \
InBlock.gif        --without-authpgsql \
InBlock.gif        --with-authmysql \
InBlock.gif        --with-mysql-libs=/usr/lib/mysql \
InBlock.gif        --with-mysql-includes=/usr/include/mysql \
InBlock.gif        --with-redhat \
InBlock.gif        --with-authmysqlrc=/etc/authmysqlrc \
InBlock.gif        --with-authdaemonrc=/etc/authdaemonrc \
InBlock.gif        --with-mailuser=postfix \
InBlock.gif        --with-mailgroup=postfix \
InBlock.gif        --with-ltdl-lib=/usr/lib \
InBlock.gif        --with-ltdl-include=/usr/include
InBlock.gif# make
InBlock.gif# make install
InBlock.gif# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
InBlock.gif# cp /etc/authdaemonrc.dist    /etc/authdaemonrc
InBlock.gif# cp /etc/authmysqlrc.dist    /etc/authmysqlrc
修改/etc/authdaemonrc 文件
InBlock.gifauthmodulelist= "authmysql"
InBlock.gifauthmodulelistorig= "authmysql"
InBlock.gifdaemons=10
3、配置其通过mysql进行邮件帐号认证

编辑/etc/authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的UID和GID。
InBlock.gifMYSQL_SERVER localhost
InBlock.gifMYSQL_PORT 3306                                     (指定你的mysql监听的端口,这里使用默认的3306)
InBlock.gifMYSQL_USERNAME    extmail            (这时为后文要用的数据库的所有者的用户名)
InBlock.gifMYSQL_PASSWORD extmail                (密码)
InBlock.gifMYSQL_SOCKET    /var/lib/mysql/mysql.sock
InBlock.gifMYSQL_DATABASE    extmail
InBlock.gifMYSQL_USER_TABLE    mailbox
InBlock.gifMYSQL_CRYPT_PWFIELD    password
InBlock.gifMYSQL_UID_FIELD    '2525'
InBlock.gifMYSQL_GID_FIELD    '2525'
InBlock.gifMYSQL_LOGIN_FIELD    username
InBlock.gifMYSQL_HOME_FIELD    concat('/var/mailbox/',homedir)
InBlock.gifMYSQL_NAME_FIELD    name
InBlock.gifMYSQL_MAILDIR_FIELD    concat('/var/mailbox/',maildir)

4、提供SysV服务脚本
InBlock.gif# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
InBlock.gif# chmod 755 /etc/init.d/courier-authlib
InBlock.gif# chkconfig --add courier-authlib
InBlock.gif# chkconfig --level 2345 courier-authlib on
InBlock.gif
InBlock.gif#echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
InBlock.gif# ldconfig -v
InBlock.gif# service courier-authlib start     (启动服务)
5、配置postfix和courier-authlib

新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
InBlock.gif#mkdir –pv /var/mailbox
InBlock.gif#chown –R postfix /var/mailbox
6、接下来重新配置SMTP 认证,编辑 /usr/lib/sasl2/smtpd.conf ,确保其为以下内容:
InBlock.gifpwcheck_method: authdaemond
InBlock.giflog_level: 3
InBlock.gifmech_list:PLAIN LOGIN
InBlock.gifauthdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
八、让postfix支持虚拟域和虚拟用户

1、编辑/etc/postfix/main.cf,添加如下内容:
InBlock.gif########################Virtual Mailbox Settings########################
InBlock.gifvirtual_mailbox_base = /var/mailbox
InBlock.gifvirtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
InBlock.gifvirtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
InBlock.gifvirtual_alias_domains =
InBlock.gifvirtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
InBlock.gifvirtual_uid_maps = static:2525
InBlock.gifvirtual_gid_maps = static:2525
InBlock.gifvirtual_transport = virtual
InBlock.gifmaildrop_destination_recipient_limit = 1
InBlock.gifmaildrop_destination_concurrency_limit = 1
InBlock.gif##########################QUOTA Settings########################
InBlock.gifmessage_size_limit = 14336000
InBlock.gifvirtual_mailbox_limit = 20971520
InBlock.gifvirtual_create_maildirsize = yes
InBlock.gifvirtual_mailbox_extended = yes
InBlock.gifvirtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
InBlock.gifvirtual_mailbox_limit_override = yes
InBlock.gifvirtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.
InBlock.gifvirtual_overquota_bounce = yes

2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
InBlock.gif# tar zxvf    extman-1.1.tar.gz
InBlock.gif# cd extman-1.1/docs
InBlock.gif# mysql -u root -p < extmail.sql
InBlock.gif# mysql -u root -p <init.sql
InBlock.gif# cp mysql*    /etc/postfix/
3、授予用户extmail和webman访问extmail数据库的权限
InBlock.gifmysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
InBlock.gifmysql> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';
InBlock.gifmysql> GRANT all privileges on extmail.* TO webman@localhost IDENTIFIED BY 'webman'; 
InBlock.gifmysql> GRANT all privileges on extmail.* TO webman@127.0.0.1 IDENTIFIED BY 'webman';
说明:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。
九、配置dovecot
因为dovecot已经安装所直接打开就行了。
InBlock.gif# vi /etc/dovecot.conf  ####要修改以下几项:
InBlock.gifmail_location = maildir:/var/mailbox/%d/%n/Maildir
InBlock.gif……
InBlock.gifauth default {
InBlock.gif        mechanisms = plain
InBlock.gif        passdb sql {
InBlock.gif                args = /etc/dovecot-mysql.conf
InBlock.gif        }
InBlock.gif        userdb sql {
InBlock.gif                args = /etc/dovecot-mysql.conf
InBlock.gif        }
InBlock.gif        ……
InBlock.gif# vim /etc/dovecot-mysql.conf                                    
InBlock.gifdriver = mysql
InBlock.gifconnect = host=localhost dbname=extmail user=extmail password=extmail
InBlock.gifdefault_pass_scheme = CRYPT
InBlock.gifpassword_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'                                                        
InBlock.gifuser_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'

接下来启动dovecot服务:
InBlock.gif# service dovecot start
InBlock.gif# chkconfig dovecot on

十、安装Extmail-1.2
下载地址:http://www.extamil.org
1、安装
InBlock.gif# tar zxvf extmail-1.2.tar.gz
InBlock.gif# mkdir -pv /var/www/extsuite
InBlock.gif# mv extmail-1.2 /var/www/extsuite/extmail
InBlock.gif# cp /var/www/extsuite/extmail/webmail.cf. default    /var/www/extsuite/extmail/webmail.cf
2、修改主配置文件
InBlock.gif#vi /var/www/extsuite/extmail/webmail.cf
InBlock.gif
InBlock.gif部分修改选项的说明:
InBlock.gif
InBlock.gifSYS_MESSAGE_SIZE_LIMIT = 5242880
InBlock.gif用户可以发送的最大邮件
InBlock.gif
InBlock.gifSYS_USER_LANG = en_US
InBlock.gif语言选项,可改作:
InBlock.gifSYS_USER_LANG = zh_CN
InBlock.gif
InBlock.gifSYS_MAILDIR_BASE = /home/domains
InBlock.gif此处即为您在前文所设置的用户邮件的存放目录,可改作:
InBlock.gifSYS_MAILDIR_BASE = /var/mailbox
InBlock.gif
InBlock.gifSYS_MYSQL_USER = db_user
InBlock.gifSYS_MYSQL_PASS = db_pass
InBlock.gif以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
InBlock.gifSYS_MYSQL_USER = extmail
InBlock.gifSYS_MYSQL_PASS = extmail
InBlock.gif
InBlock.gifSYS_MYSQL_HOST = localhost
InBlock.gif指明数据库服务器主机名,这里默认即可
InBlock.gif
InBlock.gifSYS_MYSQL_TABLE = mailbox
InBlock.gifSYS_MYSQL_ATTR_USERNAME = username
InBlock.gifSYS_MYSQL_ATTR_DOMAIN = domain
InBlock.gifSYS_MYSQL_ATTR_PASSWD = password
InBlock.gif
InBlock.gif以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称;这里默认即可
InBlock.gif
InBlock.gifSYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
InBlock.gif此句用来指明authdaemo socket文件的位置,这里修改为:
InBlock.gifSYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

3、apache相关配置

由于extmail要进行本地邮件的投递操作,故必须将运行apache服务器用户的身份修改为您的邮件投递代理的用户;本例中打开了apache服务器的suexec功能,故使用以下方法来实现虚拟主机运行身份的指定。此例中的MDA为postfix自带,因此将指定为postfix用户:
InBlock.gif# vim /etc/httpd/conf/httpd.conf
InBlock.gif添加如下内容:
InBlock.gif<VirtualHost *:80>
InBlock.gifServerName mail.magedu.com
InBlock.gifDocumentRoot /var/www/extsuite/extmail/html/
InBlock.gifScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
InBlock.gifAlias /extmail /var/www/extsuite/extmail/html
InBlock.gif</VirtualHost>

修改 cgi执行文件属主为apache运行身份用户:
InBlock.gif# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

如果您没有打开apache服务器的suexec功能,也可以使用以下方法解决:
InBlock.gif# vi /etc/httpd/httpd.conf
InBlock.gifUser postfix
InBlock.gifGroup postfix

4、依赖关系的解决

extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
InBlock.gif# tar zxvf Unix-Syslog-0.100.tar.gz
InBlock.gif# cd Unix-Syslog-0.100
InBlock.gif# perl Makefile.PL
InBlock.gif# make
InBlock.gif# make install
5、启动apache服务
InBlock.gif# service httpd start
InBlock.gif# chkconfig httpd on

十一、安装Extman-1.1
下载地址:http://www.extmail.org/
1、安装及基本配置

InBlock.gif# tar zxvf    extman-1.1.tar.gz
InBlock.gif# mv extman-1.1 /var/www/extsuite/extman

2、修改配置文件以符合本例的需要:
InBlock.gif# cp /var/www/extsuite/extman/webman.cf. default    /var/www/extsuite/extman/webman.cf
InBlock.gif# vi /var/www/extsuite/extman/webman.cf
InBlock.gif
InBlock.gifSYS_MAILDIR_BASE = /home/domains
InBlock.gif此处即为您在前文所设置的用户邮件的存放目录,可改作:
InBlock.gifSYS_MAILDIR_BASE = /var/mailbox
InBlock.gif
InBlock.gifSYS_DEFAULT_UID = 1000
InBlock.gifSYS_DEFAULT_GID = 1000
InBlock.gif此两处后面设定的ID号需更改为前而创建的postfix用户和postfix组的id号,本文使用的是2525,因此,上述两项需要修改为:
InBlock.gifSYS_DEFAULT_UID = 2525
InBlock.gifSYS_DEFAULT_GID = 2525
修改
SYS_CAPTCHA_ON = 1

SYS_CAPTCHA_ON = 0  ###这样在登录时就没有验证码了。在实际最好不要这做。

3、而后修改cgi目录的属主:
InBlock.gif# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
4、在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:
InBlock.gifScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
InBlock.gifAlias /extman /var/www/extsuite/extman/html
5、创建其运行时所需的临时目录,并修改其相应的权限:
InBlock.gif#mkdir    -pv    /tmp/extman
InBlock.gif#chown postfix.postfix    /tmp/extman

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

选择管理即可登入extman进行后台管理了。默认管理帐号为:root@extmail.org 密码为:extmail*123*
登录后就可以添加域,添加用户了。
这样就可以基于网页的邮件服务器就构建成功了。而且还可以与windows 的OE中的用户相互发送邮件了。

转载于:https://blog.51cto.com/zhou123/831897

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

邮件服务器配置+网页邮件收发 的相关文章

  • 如何用iphone导出网易云音乐的办法步骤

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 首先我是通过PP助手进行相关程序和文档进行备份 xff0c 这里我选择了要备份的网易云音乐 http www baisoujs com http www baisoujs
  • linux分区btrfs,linux btrfs文件系统及管理

    什么是btrfs xff1f Btrfs B tree文件系统 xff0c 通常念成Butter FS xff0c Better FS或B tree FS xff0c linux文件系统 xff0c 具有写时复制COW copy on wr
  • AJAX的post提交数组数据

    2019独角兽企业重金招聘Python工程师标准 gt gt gt code 前端js代码 xff1a function AlarmCondition id alarmLevel defaultOverValue isEnabled thi
  • linux 网络命令ethtool与mii-tool及nm-tool

    1 ethtool Ethtool是Linux下用于查询及设置网卡参数的命令 概要 xff1a ethtool ethX 查询ethX网口基本设置 ethtool h 显示ethtool的命令帮助 help ethtool i ethX 查
  • 使用lxc提供轻量级虚拟化

    lxc linux containers 是一种基于容器的操作系统层级的虚拟化技术 xff0c 一个容器就是一个虚拟的执行环境 xff0c 容器有效地将由单个操作系统管理的资源划分到孤立的组中 xff0c 以更好地在孤立的组之间平衡有冲突的
  • debian更新源时找不到公钥的解决办法

    W GPG error http mirrors 163 com jessie updates InRelease The following signatures couldn 39 t be verified because the p
  • esxi在线添加硬盘,系统没有识别到怎么办(重启除外)

    esxi在线添加虚拟磁盘 xff0c fdisk l没发现 xff0c 一般情况下重启服务器就可以 但是我服务器不能影响业务 xff0c 为什么新增磁盘或磁盘扩容后 xff0c Linux系统识别不到呢 xff1f 因为连接存储设备的SCS
  • CentOS 7更改阿里云源

    1 备份原镜像文件 xff0c 便于后期恢复 mv etc yum repos d CentOS Base repo etc yum repos d CentOS Base repo backup 2 下载新的CentOS Base rep
  • Ubuntu有线网络与无线网线自由切换方法

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 有的时候办公环境安全要求较高 xff0c 严格区分了工作网络 xff08 内部网络 xff09 和生活网络 xff08 Internet xff09 xff0c 通常生活网
  • 如何查看连接mysql的ip地址

    select SUBSTRING INDEX host 39 39 1 as ip count from information schema processlist group by ip
  • AutoCAD 许可管理器不起作用,或未正确安装,现在将关闭

    问题描述 重新安装了也还是这样 xff0c 而且第二次打开都跳不出申请码界面就关闭了 问题原因 xff0c 初步认为 xff1a AutoCAD 在首次弹出申请激活类型的类型时 xff0c 直接选择了网络激活 xff0c 而且没有激活成功
  • #ifndef详解

    ifndef 是 34 if not defined 34 的简写 xff0c 是预处理功能 xff08 宏定义 文件包含 条件编译 xff09 当中的条件编译 xff0c 可以根据是否已经定义了一个变量来进行分支选择 xff0c 其作用是
  • vue中watch的用法总结以及报错处理Error in callback for watcher "checkList"

    首先确认 watch是一个对象 xff0c 一定要当成对象来用 对象就有键 xff0c 有值 键 xff1a 就是你要监控的那个家伙 xff0c 比如说 route xff0c 这个就是要监控路由的变化 xff0c 或者是data中的某个变
  • 京东物流青龙系统分享

    QQ空间 腾讯朋友 新浪微博 人人网 开心网 微信 QQ好友 腾讯微博 浏览 xff1a 1102 2015年 xff0c 中国的大电商平台格局已定 xff0c 各大平台开始重视的方向已经从过去的价格战转向最后一公里和O2O的布局了 移动电
  • 彻底解决DZ大附件上传问题

    2012 4 13日更新 xff1a 因为这篇文章是很早以前写的了 xff0c 很多朋友看到了之后向我咨询大附件的问题 xff0c 但是以下部分信息已经失效 xff0c 如需了解这个问题的最新解决方案 xff0c 可以加我的QQ群 xff1
  • 前端经典面试题CSS三栏布局

    对于前端来说 xff0c 布局也是必须掌握的 xff0c 一个好的布局可以让页面看起来更美观 提到布局 xff0c 那就不得不说CSS三栏布局 这是前端面试经常会问到的一个问题 xff0c 算是基础题 所谓的三栏布局 xff0c 一般是指左
  • xmanager 注册码及评估期已过的解决办法

    注册信息 用户 xff1a admin 企业 xff1a microsoft Xshell4 0注册码 xff1a 690313 111999 999313 Xftp 4 0注册码 xff1a 101210 450789 147200 Xs
  • ntoj 808 蚂蚁的难题(八)

    蚂蚁的难题 八 时间限制 xff1a 2000 ms 内存限制 xff1a 65535 KB 难度 xff1a 5 描述 蚂蚁是一个古玩爱好者 xff0c 他收藏了很多瓶瓶罐罐 有一天 xff0c 他要将他的宝贝们一字排开 xff0c 摆放
  • CentOS 7尝试安装 phpstudy

    安装方法 xff08 phpstudy for linux V0 2公测版 xff09 使用 SSH 连接工具 连接到您的 Linux服务器后 xff0c 根据系统执行相应命令开始安装 xff08 大约2分钟完成面板安装 xff09 xff
  • asp.net 2.0中傻瓜式使用soap header

    在websevrice 中 soap header是十分重要的哦 xff0c 主要是安全性的考虑 xff0c 在asp net 2 0中 可以简单地应用soap header来 进行傻瓜式的应用 xff0c 更复杂的应用当然要更深入地去看了

随机推荐

  • Linux操作系统中对于NTFS读取目录功能的实现

    1 2 We use the same basic approach as the old NTFS driver i e we parse the 3 index root entries and then the index alloc
  • matlab练习程序(演化策略ES)

    还是这本书上的内容 xff0c 不过我看演化计算这一章是倒着看的 xff0c 这里练习的算法正好和书中介绍的顺序是相反的 演化策略是最古老的的演化算法之一 xff0c 和上一篇DE算法类似 xff0c 都是基于种群的随机演化产生最优解的算法
  • 火狐浏览器无法打开

    解决火狐浏览器无法打开的问题 xff1a 第一种方法 请先检查一下任务管理器中有没有火狐的进程 xff08 firefox exe xff09 xff0c 有的话 xff0c 请在任务管理器中强行关闭它 xff0c 然后试试用safe mo
  • 快上车项目简介(500字)

    第8组 快上车 xff0c 这是一款日常生活中非常有趣的安卓手机软件 xff0c 致力于打造一个大学生的专属娱乐创意社区 xff0c 讨论的话题轻松休闲贴近大学生活 xff0c 与在社会中十分流行的贴吧 xff0c 糗事百科类似 在快上车中
  • 挂载硬盘,提示 mount: unknown filesystem type 'LVM2_member'的解决方案

    问题现象 xff1a 由于重装linux xff0c 并且加了固态硬盘 xff0c 直接将系统装在固态硬盘中 启动服务器的时候 xff0c 便看不到原来机械硬盘的挂载目录了 xff0c 不知如何访问机械硬盘了 直接用命令 mount dev
  • 对目前市面上WPF书的浅薄感受

    目前市面上 WPF的书籍 xff0c WPF揭秘 人民邮电出版社 深入解析 WPF编程 电子工业出版社 xff0c WPF程序设计指南 电子工业出版社 WPF高级编程 清华大学出版社 我购买了前面三本 xff0c 简单的对前面三本说一些浅薄
  • 麒麟操作系统配置web服务器,银河麒麟服务器设置

    银河麒麟服务器设置 内容精选 换一换 鲲鹏软件栈汇聚各种鲲鹏兼容软件 xff0c 帮助开发者了解如何将软件移植到鲲鹏上运行 xff0c 获取操作指导和工具 来自 xff1a 其他 对于业务量访问较大的业务 xff0c 可以通过ELB设置相应
  • 技术岗的职业规划_剪辑师该如何做好职业规划?

    各位点进来的小伙伴 xff0c 我猜你们在22 28岁之间吧 这是我们人生中最迷茫最不知所措的年龄段 刚大学毕业发现学的专业跟实际工作起来相差甚远 xff0c 茫然失措 工作几年后 xff0c 猛然发现每日的工作内容都差不多 xff0c 毫
  • debian11的PVE应用

    1 在debian11中安装pve7之后 xff0c 新建虚拟机安装openeuler 启动时报错 xff1a TASK ERROR start failed QEMU exited with code 1 可以把这一段 39 kvm ig
  • cvc 降噪_你买的“降噪”耳机真的是你想要的降噪吗?

    降噪 这一个高大上得词 xff0c 在你们眼中是不是非常的有效 xff0c 面对公共交通工具热播剧外放 xff0c 街道上车水马龙的轰鸣 xff0c 咖啡厅孩子们的喧嚣 xff0c 噪音其实一直都在我们的身边 xff0c 无处不在 xff0
  • ajax post请求怎么传参_高级前端:详解手写原生Ajax的实现

    点击上方 前端印象 xff0c 选择 设为星标 第一时间关注技术干货 xff01 对于Ajax xff0c 肯定很多小伙伴都听过甚至用过了 xff0c 那么没听过的也不用着急 xff0c 本文会对Ajax进行讲解 xff0c 其次 xff0
  • java版如何使区块常加载_Minecraft指令手册

    众所周知 xff0c 人是一种健忘的生物 所以作者忘记了Java版的常加载指令 幸亏一位书友留的言提醒了我 xff0c 不然Java版的各位就只能去网上查了 然后查到 xff0c 头上却起了大雾 滑稽 那么进入正题 xff1a Java版的
  • linux点歌机硬盘,自己动手给KTV点歌机换大硬盘

    某宝买的硬盘KTV点歌机 xff0c 当时买的是单主机没要触摸屏一体的 xff0c 所以硬盘容量最大只有1TB的 原来内置的歌曲 已经挺多的了 xff0c 剩余空间所剩无几 刚好有一块闲置的2TB硬盘就打算把它换上 可以看到剩余空间只有26
  • 云服务器 信息安全,云服务器的信息安全

    云服务器的信息安全 内容精选 换一换 北京时间1月3日 xff0c Intel处理器芯片被曝出存在严重的Meltdown和Spectre安全漏洞 xff0c 漏洞详情如下 xff1a 漏洞名称 xff1a Intel处理器存在严重芯片级漏洞
  • 千方百剂显示服务器错误,千方百剂远程服务器地址

    千方百剂远程服务器地址 内容精选 换一换 已成功登录Java性能分析 待安装Guardian的服务器已开启sshd 待安装Guardian的服务器已安装JRE xff0c JRE版本要求为Huawei JDK 8或者Open JDK 8 1
  • 天地伟业客户端服务器维护,天地伟业监控维保常见问题总结

    天地伟业监控维保常见问题总结 一 天地伟业监控维保监控报警种类不当 xff1a 天地伟业监控维保问题的描述 xff1a 智能监控技术有待发展 xff0c 一些警情尚难以有效研判准确报警 部分企业误导用户 xff0c 过度承诺 如 打架斗殴
  • mac时间机器文件服务器,Mac小技巧:时间机器的使用方法和细节

    时间机器是MacBook Pro上一个备份系统的内置软件 xff0c 这款软件对于大多数工作者来说绝对是一款神器 xff0c 能够让我们无限的找回到以前的Mac备份文件 xff0c 防止一不小心删除了重要文件等问题 xff0c 而且使用起来
  • 远程连接linux桌面之XDMCP配置

    使用xdmcp连接远程linux桌面 测试环境 xff1a Centos6 gnome桌面 kdm桌面涉及修改的文件不一样 xff09 确认以下组件被安装 xff1a yum gruopinstall 34 Desktop 34 34 De
  • snapper命令技巧

    在使用Btrfs时 xff0c 会用到snapper命令 xff0c 因为btrfs目前是最新的 xff0c 而且是稳定的文件系统 xff0c 说最新其实在2012年就已经有了 xff0c 但是真正作为默认文件系统来使用 xff0c 应该是
  • 邮件服务器配置+网页邮件收发

    在 之前 的 一 篇 的 博客 写 了 一 些 关 于 邮件 服务器 的 简单 的 配置 xff0c 这 篇 添加 了 在 网页 上 的 邮件 的 收发 和 用户 认证 等 相关 的 内容 好 了 xff0c 不 多 说 了 xff0c 开