postfix中文邮件系统 简单配置                 

[Postalias  /etc/aliases  作用]
 
软件环境:
    源码包:
        postfix-2.4.6.tar.gz
        dovecot-1.1.4-tar.gz
        squirrelmail-1.4.13.tar.bz2
       all_locales-1.5.1-20060219.tar.bz2
    RHEL4/5自带rpm包:
        cyrus-sasl【提供smtp认证】
        httpd【web界面】
        mysql  per-BDI【依赖关系包】
一、配置主机名、IP地址、默认网关、DNS地址等【服务器最好给它一个主机名】
 
1、配置主机名
 # vi /etc/sysconfig/network
  HOSTNAME=mail.benet.com
 # vi /etc/hosts    【添加主机名到IP地址的映射】
 # service network restart 【重启网卡】

2、配置IP地址、默认网关、DNS地址等(略)

二、安装配置Postfix
 
1、解压安装
 #  groupadd -g 10000 postdrop【在安装postfix之前要建立postfix用户和组,不然会报错的】
 #  useradd  -u 1000 -s /sbin/nologin postfix
 # tar zxvf postfix-2.4.6.tar.gz
 # make 【安装postfix 没有./config这一步。make的时候提示你安装db4-devel,在rhel5中默认已经安装】
 # make install    【对安装过程中的提示信息,可以直接回车接受默认值即可。】
2、建立main.cf主配置文件【下面是常用的一些参数和必要的配置】
 # cd /etc/postfix/
 # vi /etc/postfix/main.cf
 myhostname = benet.com 【邮件服务器的主机名,和/etc/sysconfig/network 文件中的相同】
 mydomain = benet.com  【和邮箱的后缀名有关】
 myorigin = $mydomain   【设置邮件使用的是域名】
 inet_interfaces = all  【在所有端口监听请求】
 mydestination = $myhostname, $mydomain, localhost  【设置可接受的主机名或域名,postfix根据mydestination设置确定是否接受邮件】
 relay_domain=$mydomain 【设置可以转发的邮件来源】
 mynetworks = 127.0.0.0/8 10.100.100.0/8 【设置postfix为那些网络提供服务】
 home_mailbox = Maildir/    【邮件存储使用Maildir方式】
 message_size_limit = 31457280    【限制邮件大小30MB】
 mailbox_size_limit = 524288000   【限制邮箱空间500MB】

2、修改postfix配置文件,添加相关认证选项
 # vi /etc/postfix/main.cf  
 
 broken_sasl_auth_clients = yes
 smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_unauth_pipelining, reject_unauth_destination
 smtpd_sasl_auth_enable = yes
 smtpd_sasl_local_domain = $myhostname
 smtpd_sasl_security_options = noanonymous
 smtpd_banner = $myhostname ESMTP "Require SMTP Auth."

3、重新加载服务或重启服务【注意postfix服务的启动和停止格式】
 #  postfix reload  或 # postfix start/stop/status
 

三、为postfix提供SMTP认证支持

1、配置saslauthd服务  【默认已安装cyrus-sasl】
 # cp  /usr/lib/sasl2/Sendmail.conf   /usr/lib/sasl2/smtpd.conf
 
 # vi /etc/sysconfig/saslauthd
      SOCKETDIR=/var/run/saslauthd   【 确认这三行】
      MECH=shadow
      FLAGS=
 # service saslauthd start
 # chkconfig --level 35 saslauthd on

四、安装配置Dovecot  【提供POP3和IMAP服务。也可以用rpm包安装,安装时会提示安装mysql 和perl-DBI软件包】

1、解压安装
 #  useradd -s /sbin/nologin dovecot
 #  tar zxvf dovecot-1.1.4.tar.gz
 #  cd dovecot-1.1.4
 #  ./configure --sysconfdir=/etc
 #  make
 #  make install

2、调整dovecot.conf配置文件
 # cp /etc/dovecot-example.conf   /etc/dovecot.conf 【如果是rpm包安装的默认就是dovecot.conf】
 # vi /etc/dovecot.conf
 # disable_plaintext_auth = no    【允许使用明文密码登录】
 # ssl_disable = yes
 # protocols = pop3 imap
3、启动dovecot
 #  dovecot -c /etc/dovecot.conf  或 # service dovecot start
 【装到这里需要用用oe等测试工具试一下收发邮件.】
 【特别提示:postfix需要/etc/aliases.db的支持,用newaliases来生成】

五、安装配置Squirrelmail(提供使用邮件系统的Web界面,需要用到SMTP、IMAP)
1、解压安装
 # tar jxvf squirrelmail-1.4.13.tar.bz2  -C  /var/www/html/  【要先安装httpd】
 # cd /var/www/html/
 # mv squirrelmail-1.4.13   mail 【该一下名字】
 # cd /var/www/html/mail
 # mkdir -p attach  放附件 【可以不做】
 # chown -R  apache:apache  attach/ data/    【假设httpd的运行用户和组身份为"apache" 此不一定要做,不然访问的时候会报错,没有权限】
 # chmod 730 attach/

2.让linux支持中文:

下载了语言包all_locales-1.4.9-20070106.tar.bz2
 # tar  xjvf all_locales-1.4.9-20070106.tar.bz2
进入解压目录   # cp   locale/*     /var/www/html/mail/locale/  【将locale中的内容拷贝到/var/www/html/mail/locale目录中】
 # Setenforce 0 【临时关闭selinux ,要永久关闭修改/etc/sysconfig/selinux 文件或/etc/selinux/config 文件,这两个文件内容是相同的。rhel5默认是关闭selinux】
 #cd /var/www/html/mail/config 
 #./conf.pl 【设置语言并生成config.php文件】
 选择10 设置语言为zh_CN
 
 默认字符集为GB2312
 保存退出,重新刷新webmail页面,就成中文了。 http://ip/mail 【在rhel5中还要安装php-5-1.6.23.2不然用web浏览时会以目录的形式出现】
 
 3、配置启动httpd服务 【看要求配置】
    配置网页目录使用“DocumentRoot "/var/www/html/mail"”,…… ——过程略。
    用户访问时使用 http://ip
附加内容
1.邮件群发的实现
编辑/etc/postfix/main.cf。查找alias_maps=/etc/aliases,把注释去掉,然后编辑/etc/aliases,然后用newalias命令是更改生效
2.限制邮件大小:message_size_limit=20971520(20M),默认为10M
3.限制用户邮箱空间:1)Mailbox存储方式:mailbox_size_limit=50*1024(默认)
                    2)Maildir存储方式:virtual_mailbox_limit= (安装vda补丁后,对于1方式也生效)