当前位置: 主页 > 服务器技术 > Mail服务器 > 安装milter-limit配置postfix限制邮件账号发送量

安装milter-limit配置postfix限制邮件账号发送量

时间:2009-10-12来源:互联网 点击:
安装milter-limit配置postfix限制邮件账号发送量

1.下载
milter-limit-0.14.tar.gz
http://www.snertsoft.com/clients/downloads.php

libsnert-1.71.6.tar.gz
http://www.snertsoft.com/clients/downloads.php

sendmail.8.14.2.tar.gz
ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.14.2.tar.gz

db-4.5.20.tar.gz
http://download.oracle.com/berkeley-db/db-4.5.20.tar.gz


2.安装
安装sendmail.8.14.2
  1. tar -zxf sendmail.8.14.2.tar.gz
  2. cd sendmail-8.14.2
  3. cd libmilter/
  4. ./Build -c
  5. ./Build install
安装db4.5
  1. tar -zxf db-4.5.20.tar.gz
  2. cd db-4.5.20
  3. cd build_unix
  4. ../dist/configure
  5. make & make install
安装libsnert
  1. tar -zxf milter-limit-0.14.tar.gz
  2. tar -zxf libsnert-1.71.6.tar.gz
  3. cd com/snert/src/lib
  4. ./configure & make && make install
注以下是./configure运行完成后的结果,如果有不同,请解决依赖的问题特别是DB
  1. LibSnert/1.71.6
  2. Copyright 1996, 2009 by Anthony Howe. All rights reserved.

  3.   Platform............: FreeBSD gcc
  4.   Berkeley DB.........: 4.5 -ldb-4.5
  5.   POSIX Threads.......: yes yes
  6.   SQLite3.............: yes
  7.   Sendmail libmilter..: yes
  8.   Semaphore API.......: SYSTEMV_API
  9.   Shared Memory API...: SYSTEMV_API
  10.   CFLAGS..............: -I/usr/local/include/db45 -I/usr/home/feishu/limit/org/sqlite/include -D_THREAD_SAFE -pthread -D_REENTRANT -O2 -Wall -I${top_srcdir}/../../include
  11.   LDFLAGS.............: -L/usr/local/lib/db45 -L/usr/home/feishu/limit/org/sqlite/lib -pthread -L${top_srcdir}/../../lib
  12.   LIBS................:
  1. make build
  2. make install
安装milter-limit
  1. cd ../milter-limit
  2. ./configure --enable-run-user=postfix --enable-run-group=mail --enable-debug
  3. make build
  4. make install
配置postfix
  1. echo "smtpd_milters = unix:/var/run/milter/milter-limit.socket" >> /usr/local/etc/postfix/main.cf
启动相关服务
  1. /usr/local/etc/rc.d/postfix restart
  2. /usr/local/etc/rc.d/milter-limit.sh restart
相关代码

生成access.db的PHP脚本代码
  1. #!/usr/local/bin/php -q
  2. <?php
  3. $access = "/etc/mail/access";
  4. $fp = fopen($access,‘w+‘);

  5. $host ="localhost";
  6. $user = "FcAQQnc";
  7. $passwd = "VJuVdVFyv8PNauGr";
  8. $dbname = "tmail";

  9. $link = mysql_connect($host,$user,$passwd);
  10. mysql_select_db($dbname,$link);

  11. $query = "select * from tmail_users order by id desc";
  12. $rules = mysql_query($query,$link);

  13. while($rs = mysql_fetch_object($rules)){
  14. //限制账号一天发送量/d,可以限制一小时发送量/h
  15.         $limit = "milter-limit-From:".$rs->email."        ".$rs->sendnum."/1d"."\n";
  16.         if(fwrite($fp,$limit)===FALSE){
  17.                 echo "不能写入文件。请检查文件权限。";
  18.         }
  19. }
  20. system("/usr/sbin/makemap hash /etc/mail/access < /etc/mail/access");
  21. system("/usr/local/etc/rc.d/milter-limit.sh restart");
  22. ?>
常见问题
  1. /libexec/ld-elf.so.1: Shared object "libdb-4.5.so" not found, required by "milter-limit"
  2. /libexec/ld-elf.so.1: Shared object "libdb-4.5.so" not found, required by "milter-limit
解决方案
  1. ln -s /usr/local/BerkeleyDB.4.5/lib/libdb-4.5.so /usr/local/lib/libdb-4.5.so
http://www.milter.info/sendmail/milter-limit/#Installation
站长资讯网
. TAG: POSTFIX 发送量 邮件
推荐内容最近更新人气排行
关于我们 | 友情链接 | 网址推荐 | 常用资讯 | 网站地图 | RSS | 留言