Chinaunix首页 | 论坛 | 博客
  • 博客访问: 577701
  • 博文数量: 89
  • 博客积分: 2383
  • 博客等级: 大尉
  • 技术积分: 970
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 23:02
个人简介

Scientific Linux是重新编译的Red Hat Enterprise Linux,由费米国家加速器实验室、欧洲核研究组织以及世界各地的大学和实验室共同开发。它旨在与Red Hat Enterprise Linux完全兼容,也强调自主方便的定制,用户可以根据自己的需求做相应修改,可以使用脚本或者Anaconda给自己定制最小化的安装模式。

文章分类

全部博文(89)

文章存档

2017年(1)

2016年(2)

2013年(2)

2012年(2)

2011年(16)

2010年(13)

2009年(46)

2008年(7)

我的朋友

分类: BSD

2011-06-19 11:15:23

没有找到一篇真正实现mailman配置的完整文章,搞得我苦了1周时间,当然,主要还是对配置的理解问题。
我的邮件服务器是基于freebsd8.2 的postfix系统、etmail(我实现的笔记过一阵会贴出来)。
 

Mailman是一个比较好的邮件列表程序,功能非常强大,提供完美的Web端,权限可以分散管理,多个开源组织都在使用。

 

创建mailman用户组,执行如下命令:

pw group add mailman

 

1.      安装mailman

cd /usr/ports/mail/mailman && make MAIL_GID=mailman CGI_GID=vgroup install clean

安装时选择:POSTFIX   CHINESE

 

在此使用mailman做为MAIL_GID是为了避免在后期的维护中使用check_perms -f修复权限的时候,mailman会自动默认修改为mailman这个用户来转发邮件。而使用 CGI_GID=vgroup作为mailmanCGI执行权限是为了跟extmail/extman执行cgi时的权限一致。

 

配置/etc/rc.conf

增加一行mailman_enable="YES"

echo mailman_enable=\"YES\">> /etc/rc.conf

 

2.      配置postfix支持

touch /usr/local/mailman/data/aliases

touch /usr/local/mailman/data/virtual-mailman

/usr/local/sbin/postconf -e 'recipient_delimiter=+'

/usr/local/sbin/postconf -e 'alias_maps=hash:/etc/aliases, hash:/usr/local/mailman/data/aliases'

postalias /usr/local/mailman/data/aliases

/usr/local/sbin/postconf -e 'virtual_alias_maps = mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf, hash:/usr/local/mailman/data/virtual-mailman'

postalias /usr/local/mailman/data/aliases

postmap /usr/local/mailman/data/virtual-mailman

/usr/local/sbin/postconf -e 'default_privs = mailman'

/usr/local/etc/rc.d/postfix restart

完成mailman配置后的完整main.cf文件如下:

queue_directory = /var/spool/postfix

command_directory = /usr/local/sbin

daemon_directory = /usr/local/libexec/postfix

data_directory = /var/db/postfix

mail_owner = postfix

unknown_local_recipient_reject_code = 550

mynetworks_style = host

 

debug_peer_level = 2

debugger_command =

     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

     ddd $daemon_directory/$process_name $process_id & sleep 5

 

 

sendmail_path = /usr/local/sbin/sendmail

newaliases_path = /usr/local/bin/newaliases

mailq_path = /usr/local/bin/mailq

setgid_group = maildrop

html_directory = /usr/local/share/doc/postfix

manpage_directory = /usr/local/man

sample_directory = /usr/local/etc/postfix

readme_directory = /usr/local/share/doc/postfix

 

mydomain = xxx.com.cn

myhostname = mail.xxx.com.cn

myorigin = $mydomain

mydestination = $myhostname, localhost.$mydomain

virtual_mailbox_base = /home/data/domains

 

virtual_alias_maps =  mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf,hash:/usr/local/mailman/data/virtual-mailman

 

virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_maps.cf

 

virtual_mailbox_domains = mysql:/usr/local/etc/postfix/mysql_virtual_domains_maps.cf

 

smtpd_sasl_auth_enable = yes

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain = $myhostname

smtpd_helo_required = yes

smtpd_delay_reject = yes

disable_vrfy_command = yes

 

smtpd_client_restrictions = check_client_access hash:/usr/local/etc/postfix/client_access

 

smtpd_helo_restrictions = reject_invalid_hostname,check_helo_access hash:/usr/local/etc/postfix/helo_access

 

smtpd_sender_restrictions = reject_non_fqdn_sender,reject_unknown_sender_domain, check_sender_access hash:/usr/local/etc/postfix/sender_access

 

smtpd_data_restrictions = reject_unauth_pipelining

header_checks = regexp:/usr/local/etc/postfix/head_checks

body_checks = regexp:/usr/local/etc/postfix/body_checks

smtpd_use_tls = yes

smtpd_tls_auth_only = no

smtp_tls_CAfile = /usr/local/etc/postfix/certs/cacert.pem

smtp_tls_cert_file = /usr/local/etc/postfix/certs/mycert.pem

smtpd_tls_CAfile = /usr/local/etc/postfix/certs/cacert.pem

smtpd_tls_cert_file = /usr/local/etc/postfix/certs/mycert.pem

smtpd_tls_key_file = /usr/local/etc/postfix/certs/mykey.pem

smtpd_tls_received_header = yes

smtpd_tls_loglevel = 3

smtpd_starttls_timeout = 60s

virtual_transport = maildrop:

 

maildrop_destination_concurrency_limit = 1

maildrop_destination_recipient_limit = 1

 

content_filter = smtp-amavis:[localhost]:10024

 

receive_override_options = no_address_mappings

recipient_delimiter = +

alias_maps = hash:/etc/aliases, hash:/usr/local/mailman/data/aliases

default_privs = mailman

 

smtpd_recipient_restrictions =

    permit_mynetworks,

    permit_sasl_authenticated,

    reject_unauth_destination,

    reject_unauth_pipelining,

    reject_invalid_hostname,

    check_policy_service inet:127.0.0.1:10030

3.      配置mailman

cd /usr/local/mailman

/usr/local/mailman/bin/genaliases

chown -R mailman:mailman /usr/local/mailman/data/aliases*

chown -R mailman:mailman /usr/local/mailman/data/virtual-mailman*

chmod 664 /usr/local/mailman/data/aliases*

chmod 664 /usr/local/mailman/data/virtual-mailman*

cp -Rfp icons/ cgi-bin/icons

cp /usr/local/www/icons/powerlogo.gif cgi-bin/icons/

 

修改管理员密码:bin/mmsitepass我将密码设为xxxxxxxx

vi /usr/local/mailman/Mailman/mm_cfg.py,增加如下内容

MTA = 'Postfix'

#POSTFIX_STYLE_VIRTUAL_DOMAINS = ['vistualdomain2vistuldomain3']

#特别注意关掉这条,因为我在这个邮件服务器上只有一个虚拟域名,等于是vistul domain1,而POSTFIX_STYLE_VIRTUAL_DOMAINS是专门为vistualdomain2 vistuldomain3 准备的,只有一个域名的时候,都写到这里就有发生提示“user unknown.  Command output: Invalid user specified.”的错误。

add_virtualhost('mail.xxx.com.cn')

myhostname = 'mail.xxx.com.cn'

mydomain = 'xxx.com.cn'

DEFAULT_EMAIL_HOST = 'mail.xxx.com.cn'

DEFAULT_URL_HOST = 'lists.xxx.com.cn'

DEFAULT_SERVER_LANGUAGE = 'zh_CN'

4.      创建一个邮件列表mailman

mailman列表为必须创建的,管理员邮箱使用,密码使用soft.43>

bin/newlist mailman

显示:root@mail38/usr/local/mailman# bin/newlist mailman

Enter the email of the person running the list:

Initial mailman password:xxxxxxxx

Hit enter to notify mailman owner...回车退出

 

5.      配置apache支持mailman

vi /usr/local/etc/apache22/Includes/extmail.conf中添加如下内容。

 

    ServerName lists.xxx.com.cn

    DocumentRoot /usr/local/mailman/cgi-bin/

    ScriptAlias /mailman "/usr/local/mailman/cgi-bin/"

    Alias /pipermail /usr/local/mailman/archives/public/

   

        AddDefaultCharset Off

   

   

        Options FollowSymLinks ExecCGI

        AllowOverride None

        Order allow,deny

        Allow from all

   

 

改造后的extmail.conf是这样的:

NameVirtualHost *:80

        ServerName mail.xxx.com.cn

            DocumentRoot /usr/local/www/extmail/html/

 

            ScriptAlias /extmail/cgi /usr/local/www/extmail/cgi/

            Alias /extmail /usr/local/www/extmail/html/

            ScriptAlias /extman/cgi "/usr/local/www/extman/cgi/"

            Alias /extman "/usr/local/www/extman/html/"

 

            

                SetHandler cgi-script

                Options +ExecCGI

           

           

                    AddDefaultCharset UTF-8

                AllowOverride None

                Options None

                Order allow,deny

                Allow from all

           

 

#    SuexecUserGroup vmail vmail

 

 

                ServerName lists.xxx.com.cn

            DocumentRoot /usr/local/mailman/cgi-bin/

            ScriptAlias /mailman/ "/usr/local/mailman/cgi-bin/"

            Alias /pipermail/ "/usr/local/mailman/archives/public/"

           

        AddDefaultCharset Off

           

           

        Options FollowSymLinks ExecCGI

        AllowOverride None

        Order allow,deny

        Allow from all

           

重启APACHE

/usr/local/sbin/apachectl restart

 

6.      测试通过web使用mailman

  检测配置文件完整性并加以修复:/usr/local/mailman/bin/check_perms –f

  修正归档文件的权限:chmod o-x /usr/local/mailman/archives/private

改变归档目录下的各个目录的权限

# cd  /usr/local/mailman/archives

# chown  vuser private

# chmod o-x private

 

  使用方法:添加一个邮件列表:

  mail# /usr/local/mailman/bin/newlist nou_all

  然后显示:

Enter the email of the person running the list:

Initial zxtestlist password: XXXXX

Hit enter to notify zxlist owner...

 

然后任何人可以网上发邮件,通过设置好的管理员对邮件进行审核,审核选项有丢弃、拒绝、批准等等,通过批准后邮件就可以发给全部的列表成员了。

 

  把用户添加到邮件列表里测试,建一个文本文件,比如maillists.txt,一行一个邮件地址,然后执行如下命令:

  mail# /usr/local/mailman/bin/add_members -n maillists.txt zxtestlist

  不过这可以通过网页来增加用户(),

邮件列表的配置

Default.pymm_cfg.py的配置是针对全局的,对全局配置文件的修改不会影响到已经存在的邮件列表。mailman提供了config_list这个命令来对单个邮件列表进行配置,先导出该邮件列表的配置:

mail# /usr/local/mailman/bin/config_list -o /tmp/config mailman

然后修改/tmp/config文件,里面有很多选项,可以根据自己的要求修改,比如加上回复到邮件列表的邮件头、去掉mailman自动加的边脚等等,最后把这个配置文件导回给邮件列表就可以了:

mail# /usr/local/mailman/bin/config_list -i /tmp/config mailman

 

  通过web访问:

           

                

                

 

 

-------------------------------------------------------------------------

经过一段时间的实际使用,发现mailman真的很好,特殊适合用来给企业内部群发邮件,我把不同年级的学生分成不同的邮件列表,然后发给需要群发邮件的相关部门,他们群发邮件后,都需要我审核后才会发到学生邮箱中,很可靠。

阅读(4766) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~