云中帆 发表于 2006-10-13 00:04:03

extmail 自动安装程序 for freebsd 6.0/6.1(2006-10-12加强版)

extmail 自动安装程序 for freebsd 6.0/6.1(2006-10-12加强版)是在fengyong 的mail_v2.0基础上进行扩展完善的http://www.extmail.org/forum/archive/2/0607/2100.html


功能描述一下:(fengyong 的mail_v2.0提到的我就不说了)

1\修改了ExtMan/0.16-pre1的代码,完善了允许的服务(webmail\smtp auth\pop3\imap\netdisk),已经生效的控制权限有(webmail\smtp auth)下一步将继续增强扩展

2\结合POSTFIX和ExtMan/0.16-pre1增加了(内网用户)功能,激活内网用户,该帐号只能向本域或授权域发送邮件,未激活内网用户的标准帐号可向任何域发送邮件

3\整合了进出邮件备份的功能,incoming@domain.com/outgoing@domain.com 分别对进出邮件进行备份

4\修改ExtMail 0.24-pre8使其支持ExtMan/0.16-pre1对webmail设定的支持

5\增加了授权域数据库主要用来支持内网帐号的应用,目前需手动在数据库内增删,以后会在ExtMan/0.16-pre1里支持操作

6\增加了垃圾邮件过滤(SpamAssassin)配置文档,

7\增加了安装 PHP5/php5-extensions/phpMyAdmin 完装完毕即可使用



下一版本:

1\完善邮件列表功能
2\完善允许的服务(pop3\imap\netdisk)
3\增加ExtMan/0.16-pre1对授权域的操作
4\增加LDAP的自动安装
5\增加Extmail里的(全局地址本)的自动安装配置
6\Maildrop + ExtMail 实现过滤/自动回复/转发等
7\用户自定义白名单,黑名单的功能


希望能尽可能的解决繁琐的配置和安装过程,有时间我会补充一份配置说明,大家可以根据需要,自行
修改调整!





安装前请参照压缩包内的(INSTALL_README)文档,里面是从开始到结束,所有需要进行选择项配置说明!
Http://down.21sun.net/mail_v.1.0.0.0.tar.gz












(INSTALL_README)文档
=================================================
Options for gettext 0.14.5_2
-------------------------------------------------
EXAMPLES install example files
HTMLMAN   install man pages in HTML format
-------------------------------------------------



Options for courier-imap 4.1.1,1
-------------------------------------------------
OPENSSL   Build with OpenSSL support
[ ] FAM       Build in fam support for IDLE command
[ ] DRAC       Build in DRAC support
[ ] TRASHQUOTA   Include deleted mails in the quota
[ ] GDBM       Use gdbm db instead of system bdb
[ ] IPV6       Build with IPv6 support
[ ] AUTH_LDAP   LDAP support
AUTH_MYSQL   MySQL support
[ ] AUTH_PGSQL   PostgreSQL support
[ ] AUTH_USERDB Userdb support
[ ] AUTH_VCHKPW Vpopmail/vchkpw support
-------------------------------------------------


Options for postfix 2.3.3,1
-------------------------------------------------
PCRE   Perl Compatible Regular Expressions
[ ] SASL   Cyrus SASLv1 (Simple Auth. and Sec. Layer)
SASL2   Cyrus SASLv2 (Simple Auth. and Sec. Layer)
[ ] DOVECOT   Dovecot SASL authentication method
[ ] SASLKRB   If your SASL req. Kerberos select this option
[ ] SASLKRB5 If your SASL req. Kerberos5 select this option
[ ] SASLKMIT If your SASL req. MIT Kerberos5 select this option
TLS   Enable SSL and TLS support
[ ] BDB   Berkeley DB (choose version with WITH_BDB_VER)
MYSQL   MySQL maps (choose version with WITH_MYSQL_VER)
[ ] PGSQL   PostgreSQL maps (choose with DEFAULT_PGSQL_VER)
[ ] OPENLDAP OpenLDAP maps (choose ver. with WITH_OPENLDAP_VER)
[ ] CDB   CDB maps lookups   
[ ] NIS   NIS maps lookups   
VDA   VDA (Virtual Delivery Agent)         
[ ] TEST   SMTP/LMTP test server and generator
-------------------------------------------------



Options for p5-Mail-SpamAssassin 3.1.5
-------------------------------------------------
AS_ROOT   Run spamd as root (recommended)
[ ] DOMAINKEYS   DomainKeys support
SSL         Build with SSL support for spamd/spamc
MYSQL       Add MySQL support
[ ] PGSQL       Add PostreSQL support
[ ] RAZOR       Add Vipul's Razor support
[ ] SPF_QUERY   Add SPF query support
[ ] RELAY_COUNTRY Relay country support
TOOLS       Install SpamAssassin tools
-------------------------------------------------



Options for amavisd-new 2.4.2_3,1   
-------------------------------------------------
BDB       Use BerkeleyDB for nanny/cache/snmp
[ ] SQLITE   Use SQLite for lookups/logging/quarantine
MYSQL       Use MySQL for lookups/logging/quarantine
[ ] PGSQL       Use PgSQL for lookups/logging/quarantine
[ ] LDAP       Use LDAP for lookups
SASL       Use SASL authentication
MILTER   Sendmail milter support
[ ] NEW_MILTER   New sendmail milter support (external module)
SPAMASSASSIN Use mail/p5-Mail-SpamAssassin
[ ] P0F       Passive operating system fingerprinting
[ ] FILE       Use newer file(1) utility from ports
RAR       RAR support with archivers/rar
UNRAR       RAR support with archivers/unrar
ARJ       ARJ support with archivers/arj
UNARJ       ARJ support with archivers/unarj
LHA       LHA support with archivers/lha
ARC       ARC support with archivers/arc
NOMARCH   ARC support with archivers/nomarch
CAB       CAB support with archivers/cabextract
RPM       RPM support with archivers/rpm2cpio
ZOO       ZOO support with archivers/zoo
UNZOO       ZOO support with archivers/unzoo
LZOP       LZOP support with archivers/lzop
FREEZE   FREEZE support with archivers/freeze
TNEF       Add external tnef decoder converters/tnef
-------------------------------------------------





Options for clamav 0.88.4
-------------------------------------------------
MILTER   Compile the milter interface
CURL   Support URL downloading
LIBUNRAR Support for external Unrar library
STDERR   Print logs to stderr instead of stdout
-------------------------------------------------



Options for php5 5.1.6
-------------------------------------------------
[ ] CLI   Build CLI version
[ ] CGI   Build CGI version
APACHE   Build Apache module
[ ] DEBUG   Enable debug
[ ] SUHOSIN   Enable Suhosin protection system
MULTIBYTE Enable zend multibyte support
[ ] IPV6   Enable ipv6 support
[ ] REDIRECT   Enable force-cgi-redirect support (CGI only)
[ ] DISCARD   Enable discard-path support (CGI only)
[ ] FASTCGI   Enable fastcgi support (CGI only)
[ ] PATHINFO   Enable path-info-check support (CGI only)
-------------------------------------------------



Options for php5-extensions 1.0
-------------------------------------------------
BCMATH   bc style precision math functions
BZ2   bzip2 library support
CALENDAR   calendar conversion support
CTYPE   ctype functions
CURL   CURL support   
[ ] DBA   dba support   
[ ] DBASE   dBase library support
DOM   DOM support
[ ] EXIF   EXIF support
[ ] FILEINFO   fileinfo support
[ ] FILEPRO   filePro support
[ ] FRIBIDI   FriBidi support
FTP   FTP support
GD       GD library support
[ ] GETTEXT   gettext library support
[ ] GETTEXT   gettext library support
[ ] GMP   GNU MP support
HASH   HASH Message Digest Frameworkx
ICONV   iconv support
IMAP   IMAP support   
[ ] INTERBASE Interbase 6 database support (Firebird)
[ ] LDAP   OpenLDAP support   
[ ] MBSTRING   multibyte string support
MCRYPT   Encryption support   
MHASH   Crypto-hashing support
[ ] MING   ming shockwave flash support
[ ] MSSQL   MS-SQL database support
MYSQL   MySQL database support
[ ] MYSQLI   MySQLi database support
[ ] NCURSES   ncurses support (CLI only)
[ ] ODBC   unixODBC support   
[ ] OPENSSL   OpenSSL support
[ ] PANDA   panda support
[ ] PCNTL   pcntl support (CLI only)
PCRE   Perl Compatible Regular Expression support
[ ] PDF   PDFlib support (implies GD)
PDO   PHP Data Objects Interface (PDO)
[ ] PGSQL   PostgreSQL database support
POSIX   POSIX-like functions   
[ ] PSPELL   pspell support
[ ] READLINE   readline support (CLI only)
[ ] RECODE   recode support
SESSION   session support
[ ] SHMOP   shmop support
SIMPLEXML simplexml support
[ ] SNMP   SNMP support   
[ ] SOAP   SOAP support   
[ ] SOCKETS   sockets support
SQLITE   sqlite support
[ ] SYBASE_CT Sybase database support
[ ] SYSVMSG   System V message support
[ ] SYSVSEM   System V semaphore support
[ ] SYSVSHM   System V shared memory support
[ ] TIDY   TIDY support   
TOKENIZER tokenizer support   
[ ] WDDX   WDDX support (implies XML)
XML   XML support   
XMLREADER XMLReader support   
[ ] XMLRPC   XMLRPC-EPI support   
XMLWRITER XMLWriter support
[ ] XSL   XSL support (Implies DOM)
[ ] YAZ   YAZ support (ANSI/NISO Z39.50)
ZIP   ZIP support   
ZLIB   ZLIB support



Options for phpMyAdmin 2.9.0.2
-------------------------------------------------
BZ2   bzip2 library support
GD   GD library support
MYSQLI   Improved MySQL support
OPENSSL   OpenSSL support
PDF   PDFlib support (implies GD)
ZLIB   ZLIB support
MCRYPT   MCrypt library support
MBSTRING Multi-byte character-set string support













对于,已经安装好了EXTMAIL和POSTFIX的用户可以参照下面的文档来修改你的Extmail/Extman

并参照mail_v.1.0.0.0.tar.gz压缩包内的Conf 目录下的配置文档来设置你的相关配置文件

有关新增加的表和字段,请对比压缩包内的 Conf 目录下的 extmail.sql 文档自行建立


========================================================
----------------------------------------------------------------
1、修改用户增加和编辑界面,增加激活内网用户的操作界面
----------------------------------------------------------------
vi /usr/local/www/cgi-bin-dist/extman/html/standard/edit_user.html

找到以下代码72行处:
<tr>
    <td><%active%></td><td><input name=active type=checkbox <!-- IF ACTIVE -->checked<!-- END ACTIVE-->></td>
</tr>

在其下面增加:
<tr>
    <td><%lanuser%></td><td><input name=lanuser type=checkbox <!-- IF LANUSER -->checked<!-- END LANUSER-->></td>
</tr>







----------------------------------------------------------------
2、修改用户增加和编辑界面,增加激活内网用户语言包内容
----------------------------------------------------------------
vi /usr/local/www/cgi-bin-dist/extman/lang/zh_CN

找到以下代码78行处
%lang_user = (
.
.
.
lanuser => '激活',

在其下面增加一行
lanuser => '激活内网用户',


vi /usr/local/www/cgi-bin-dist/extman/lang/en_CN

找到以下代码78行处:
%lang_user = (
.
.
.
active => 'Active',

在其下面增加一行
lanuser => 'Active Lan User',






----------------------------------------------------------------
3、vi /usr/local/www/cgi-bin-dist/extman/libs/Ext/Mgr/MySQL.pm
----------------------------------------------------------------
首先修正一个显示的小BUG

查找
push @$srv, 'netdisk' if ($opt{srv_imap});

替换成
push @$srv, 'netdisk' if ($opt{srv_netdisk});




找到191行处:
sub get_users_list {
my $self = shift;
my $SQL = "SELECT * FROM mailbox WHERE domain='$_'";
my $rs = $self->get_entries($SQL);
my $arr = []; # null ARRAY ref
foreach my $ref (@$rs) {
    push @$arr, {
      mail => $ref->{username},
      cn => $ref->{name},
      domain => $ref->{domain},
      uidnumber => $ref->{uidnumber},
      gidnumber => $ref->{gidnumber},
      uid => $ref->{uid},
      netdiskquota => $ref->{netdiskquota},
      active => $ref->{active} ? 1 : 0,
在其下面增加:
      lanuser => $ref->{smtp_local_limit} ? 1 : 0,



找到281行处:
sub add_user {
my $self = shift;
my %opt = @_;
my $db = $self->{dbh};

my $ctype = $self->{crypt_type};
my $srv = [];
push @$srv, 'webmail' if ($opt{srv_webmail});
push @$srv, 'smtpauth' if ($opt{srv_smtpauth});
push @$srv, 'pop3' if ($opt{srv_pop3});
push @$srv, 'imap' if ($opt{srv_imap});
push @$srv, 'netdisk' if ($opt{srv_imap});

$srv = join(',',@$srv); # XXX
my $passwd = $self->encrypt($ctype, $opt{passwd});
my $active = $opt{active} ? 1 : 0;
在其下面增加:
my $lanuser = $opt{lanuser} ? 1 : 0;
my $webmail_limit = $opt{srv_webmail} ? 1 : 0;
my $smtp_limit = $opt{srv_smtpauth} ? 1 : 0;
my $pop3_limit = $opt{srv_pop3} ? 1 : 0;
my $imap_limit = $opt{srv_imap} ? 1 : 0;
my $netdisk_limit = $opt{srv_imap} ? 1 : 0;


向下几行,找到296行处
$db->do("INSERT into mailbox(
      username,
      uid,
      password,
      name,
      maildir,
      homedir,
      quota,
      netdiskquota,
      domain,
      uidnumber,
      gidnumber,
      createdate,
      expiredate,
      active,
在其下面增加
      webmail_limit,      
      smtp_local_limit,
      smtp_limit,
      pop3_limit,
      imap_limit,
      netdisk_limit,


向下几行,找到311行处
      '$opt{mail}',
      '$opt{uid}',
      '$passwd',
      '$opt{cn}',
      '$opt{maildir}',
      '$opt{homedir}',
      '$opt{quota}',
      '$opt{netdiskquota}',
      '$opt{domain}',
      '$opt{uidnumber}',
      '$opt{gidnumber}',
      '$opt{create}',
      '$opt{expire}',
      '$active',
在其下面增加
      '$webmail_limit',
      '$lanuser',
      '$smtp_limit',
      '$pop3_limit',
      '$imap_limit',
      '$netdisk_limit',


找到以下代码处501行
sub modify_user {
my $self = shift;
my %opt = @_;
my $db = $self->{dbh};

my $srv = [];
push @$srv, 'webmail' if ($opt{srv_webmail});
push @$srv, 'smtpauth' if ($opt{srv_smtpauth});
push @$srv, 'pop3' if ($opt{srv_pop3});
push @$srv, 'imap' if ($opt{srv_imap});
push @$srv, 'netdisk' if ($opt{srv_imap});

$srv = join(',',@$srv); # XXX
my $active = $opt{active} ? 1 : 0;
在其下面增加
my $lanuser = $opt{lanuser} ? 1 : 0;
my $smtp_limit = $opt{srv_smtpauth} ? 1 : 0;
my $webmail_limit = $opt{srv_webmail} ? 1 : 0;
my $pop3_limit = $opt{srv_pop3} ? 1 : 0;
my $imap_limit = $opt{srv_imap} ? 1 : 0;
my $netdisk_limit = $opt{srv_imap} ? 1 : 0;


再向下几行,找到如下代码517行处
$db->do("UPDATE mailbox set
      name='$opt{cn}',
      quota='$opt{quota}',
      netdiskquota='$opt{netdiskquota}',
      uidnumber='$opt{uidnumber}',
      gidnumber='$opt{gidnumber}',
      expiredate='$opt{expire}',
      active='$active',
在其下面增加:
      smtp_local_limit='$lanuser',
      smtp_limit='$smtp_limit',
      smtp_local_limit='$lanuser',
      webmail_limit='$webmail_limit',
      pop3_limit='$pop3_limit',
      imap_limit='$imap_limit',
      netdisk_limit='$netdisk_limit',


找到如下代码处637行:
sub get_user_info {
my $self = shift;
my $user = $_;
my $domain = $user;

$domain =~ s#^([^\@]+)@##;
my $SQL = "SELECT * FROM mailbox where username='$user'";
my $ref = $self->get_entry($SQL);
return undef unless ($ref);
return {
    mail => $ref->{username},
    cn => $ref->{name},
    domain => $ref->{domain},
    uidnumber => $ref->{uidnumber},
    gidnumber => $ref->{gidnumber},
    uid => $ref->{uid},
    netdiskquota => $ref->{netdiskquota},
    active => $ref->{active} ? 1 : 0,
在其下面增加
    lanuser => $ref->{smtp_local_limit} ? 1 : 0,



----------------------------------------------------------------
4、修改下面的文件

vi /usr/local/www/cgi-bin-dist/extman/libs/Ext/MgrApp/User.pm
----------------------------------------------------------------
找到如下代码:(约57行处)
sub add_user {
my $self = shift;
my $tpl = $self->{tpl};
my $mgr = $self->{backend};
my $q = $self->{query};
my $sys = $self->{sysconfig};

$tpl->assign(
    HAVE_USER => 1,
    NEWADD => 1,
    EXPIRE => $default_expire,
    ACTIVE => 1,
在其下面增加:
   LANUSER => 1,




向下找到如下代码:(130行处)
sub edit_user {
my $self = shift;
my $tpl = $self->{tpl};
my $mgr = $self->{backend};
my $q = $self->{query};
my $multiplier = $self->{sysconfig}->{SYS_QUOTA_MULTIPLIER} || '1048576';

my $user = $q->cgi('user') || $q->cgi('username').'@'.$q->cgi('domain');
my $ui = $mgr->get_user_info($user);
my $charset = $self->{sysconfig}->{SYS_CHARSET} || $lang_charset;

return 0 unless($ui);

# permission validation
unless ($self->valid_perm($ui->{domain})) {
    $self->error('Access denied');
    return 0;
}

my ($uname) = ($ui->{mail} =~ m!(.*)@.*!);

$tpl->assign(HAVE_USER => 1);
$tpl->assign(
    MAIL => $ui->{mail},
    UNAME => $uname,
    NAME => $mgr->decode_utf8($charset, $ui->{cn} || $ui->{username}),
    DOMAIN => $ui->{domain},
    UID => $ui->{uidnumber},
    GID => $ui->{gidnumber},
    EXPIRE => $ui->{expire},
    PASSWD => "",
    QUOTA => $self->quota2num($ui->{quota})/$multiplier,
    NDQUOTA => $self->quota2num($ui->{netdiskquota})/$multiplier,
    ACTIVE => $ui->{active},
在其下面增加:
    LANUSER => $ui->{lanuser},




向下找到如下代码:(209行处)
      $rc = $mgr->modify_user(
          user => "$user\@$domain",
          domain => $domain,
          cn => $mgr->encode_utf8($charset, $q->cgi('cn')),
          uidnumber => $q->cgi('uid'),
          gidnumber => $q->cgi('gid'),
          expire => $q->cgi('expire'),
          passwd => $pwd1,
          quota => $self->num2quota($multiplier*$q->cgi('quota')),
          netdiskquota => $self->num2quota($multiplier*$q->cgi('netdiskquota')),
          active => $q->cgi('active'),
在其下面增加
         lanuser => $q->cgi('lanuser'),



向下找到如下代码(262行处)
      $rc = $mgr->add_user(
          mail => "$user\@$domain",
          domain => $domain,
          uid => $user,
          cn => $mgr->encode_utf8($charset, $q->cgi('cn')),
          uidnumber => $q->cgi('uid'),
          gidnumber => $q->cgi('gid'),
          # new user attributes here
          create => strftime("%Y-%m-%d %H:%M:%S", localtime),
          expire => $q->cgi('expire'),
          passwd => $pwd1,
          quota => $self->num2quota($multiplier*$q->cgi('quota')),
          maildir => "$domain/$user/Maildir/",
          homedir => "$domain/$user",
          netdiskquota => $self->num2quota($multiplier*$q->cgi('netdiskquota')),
          active => $q->cgi('active'),
在其下面增加
          lanuser => $q->cgi('lanuser'),


5、修改以下文件,来达到对WEBMAIL的限制
vi /usr/local/www/cgi-bin-dist/extmail/libs/Ext/Auth/MySQL.pm

找到 70 行如下代码
    $sql = "SELECT * FROM $self->{opt}->{table} WHERE $username='$params'";
修改为:
    $sql = "SELECT * FROM $self->{opt}->{table} WHERE $username='$params' and webmail_limit='1'";

钉子 发表于 2006-10-13 09:28:27

谢谢云中帆 来到5dmail并把最新的资料提供。

zhoujian0502 发表于 2006-11-30 22:15:56

下载不了啊.

adriannet 发表于 2006-12-1 17:55:58

谢谢了,顶一下。。
页: [1]
查看完整版本: extmail 自动安装程序 for freebsd 6.0/6.1(2006-10-12加强版)