免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 7467 | 回复: 17
打印 上一主题 下一主题

[FreeBSD] Install qmail on FreeBSD 6.2 via ports [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-05 11:09 |只看该作者 |倒序浏览
作者: 李忍 , QQ: 235749 ,  Email:  levopat_AT_gmail_DOT_com , MSN:  pat.li_AT_msn_DOT_com


Step 1 *Install qmail*

  1. cd /usr/ports/mail/qmail
  2. make config
复制代码


[quote]#deselect following
[ ] QMTPC_PATCH            send email using qmtp protocol
[ ] RCDLINK                create rc.d/qmail.sh
[ ] QEXTRA                 enable QUEUE_EXTRA e-mail copy featur

  1. make install clean
  2. /var/qmail/scripts/enable-qmail
复制代码

[/quote]

Step 2 *Create qmail's boot script*

  1. vi /var/qmail/rc
复制代码

  1. env env - PATH="/var/qmail/bin:$PATH" \
  2. qmail-start ./Maildir/
复制代码

  1. chmod +x /var/qmail/rc
  2. /var/qmail/configure/config-fast `hostname`
复制代码



Step 3 *Install vpopmail*


  1. mysqladmin -uroot -p create vpopmail
  2. mysql -u root -p mysql
  3. mysql> GRANT ALL ON *.* TO "vpopmail"@"localhost" IDENTIFIED BY "vpopmail";
  4. mysql> FLUSH PRIVILEGES;
复制代码
  1. cd /usr/ports/mail/vpopmail
  2. make WITH_MYSQL=yes \
  3. WITH_MYSQL_SERVER=localhost \
  4. WITH_MYSQL_USER=vpopmail \
  5. WITH_MYSQL_PASSWD=vpopmail\
  6. WITH_MYSQL_DB=vpopmail \
  7. WITH_MYSQL_LIMITS=yes \
  8. WITH_SMTP_AUTH_PATCH=yes \
  9. install clean
复制代码


[quote]#Options for ucspi-tcp 0.88_2
#select all
[/quote]


Step 4 *Install maildrop*

  1. cd /usr/ports/mail/maildrop/
  2. make install clean
复制代码
  1. pw user mod vpopmail -s /bin/sh
复制代码


[quote]vi /usr/local/etc/mailfilter.conf

  1. `test -f .whitelist`
  2. if ($RETURNCODE==0)
  3. {
  4.     if ($SENDER ne '' && lookup($SENDER, '.whitelist'))
  5.         to ./Maildir/
  6. }

  7. `test -f .blacklist && test -d ./Maildir/.Trash`
  8. if ($RETURNCODE==0)
  9. {
  10.   if ($SENDER ne '' && lookup($SENDER, '.blacklist'))
  11.     to ./Maildir/.Trash/
  12. }

  13. # size less 100K
  14. if($SIZE < 102400)
  15. {
  16.   exception {
  17.     xfilter "/usr/local/bin/spamc -f -u $EXT@$HOST"
  18.   }
  19. }

  20. if(/^X-Spam-Flag: *YES/)
  21. {
  22.   `test -d ./Maildir/.Trash`
  23.   if ($RETURNCODE==0)
  24.     to ./Maildir/.Trash/
  25. }

  26. exception {
  27.   to ./Maildir/
  28. }
复制代码
# ls -l /usr/local/etc/mailfilter.conf

  1. -rw-------  1 vpopmail  vchkpw  525 Apr  1 16:03 /usr/local/etc/mailfilter.conf
复制代码



[/quote]


Step 5 *Install qmailadmin*
  1. cd /usr/ports/mail/qmailadmin
  2. sed 's/cgi-bin.default/cgi-bin/g' Makefile > Makefile.tmp
  3. sed 's/data.default/data/g' Makefile.tmp > Makefile
复制代码

  1. make WITH_MODIFY_QUOTA=yes \
  2. WITH_DOMAIN_AUTOFILL=yes \
  3. WITH_SPAM_DETECTION=yes \
  4. SPAM_COMMAND='|preline /usr/local/bin/maildrop /usr/local/etc/mailfilter.conf' \
  5. install
复制代码



  1. /usr/local/vpopmail/bin/vadddomain `hostname` 123
  2. /usr/local/vpopmail/bin/vadduser test@`hostname` 123
复制代码



Step 6 *Install daemontools*
  1. cd /usr/ports/sysutils/daemontools
  2. make install clean
复制代码

[quote]#Options for daemontools 0.76_12
#select default

  1. mkdir -p /var/log/qmail/qmail-smtpd
  2. mkdir -p /var/log/qmail/qmail-pop3d
  3. mkdir -p /var/log/qmail/qmail-send

  4. chmod -R 755 /var/log/qmail
  5. chown -R qmaill:wheel /var/log/qmail
复制代码


#configure svscan
  1. mkdir /var/qmail/supervise
  2. chmod 755 /var/qmail/supervise

  3. mkdir /var/qmail/supervise/qmail-smtpd
  4. mkdir /var/qmail/supervise/qmail-smtpd/log
  5. chmod +t /var/qmail/supervise/qmail-smtpd

  6. mkdir /var/qmail/supervise/qmail-send
  7. mkdir /var/qmail/supervise/qmail-send/log
  8. chmod +t /var/qmail/supervise/qmail-send

  9. mkdir /var/qmail/supervise/qmail-pop3d
  10. mkdir /var/qmail/supervise/qmail-pop3d/log
  11. chmod +t /var/qmail/supervise/qmail-pop3d

  12. mkdir /service
  13. chmod 755 /service
  14. ln -s /var/qmail/supervise/* /service/
复制代码
[/quote]


Step 7 *Create smtp send pop3 script*

[quote]vi /var/qmail/supervise/qmail-pop3d/run
  1. #!/bin/sh
  2. HOSTNAME=`/bin/hostname`
  3. exec /usr/local/bin/tcpserver -H -R -v -c100 0 110 \
  4. /var/qmail/bin/qmail-popup $HOSTNAME \
  5. /usr/local/vpopmail/bin/vchkpw \
  6. /var/qmail/bin/qmail-pop3d Maildir \
  7. 2>&1
复制代码

vi /var/qmail/supervise/qmail-pop3d/log/run

  1. #!/bin/sh
  2. exec /usr/local/bin/setuidgid qmaill \
  3. /usr/local/bin/multilog t s100000 n20 \
  4. /var/log/qmail/qmail-pop3d \
  5. 2>&1
复制代码

  1. chmod 755 /var/qmail/supervise/qmail-pop3d/run
  2. chmod 755 /var/qmail/supervise/qmail-pop3d/log
  3. chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
复制代码

vi /var/qmail/supervise/qmail-smtpd/run

  1. #!/bin/sh
  2. QMAILDUID=`/usr/bin/id -u qmaild`
  3. NOFILESGID=`/usr/bin/id -g qmaild`
  4. exec /usr/local/bin/tcpserver -p -R -x /usr/local/vpopmail/etc/tcp.smtp.cdb \
  5. -u"$QMAILDUID" -g"$NOFILESGID" -v -c100 0 smtp \
  6. rblsmtpd \
  7. /var/qmail/bin/qmail-smtpd \
  8. 2>&1
复制代码

vi /var/qmail/supervise/qmail-smtpd/log/run

  1. #!/bin/sh
  2. exec /usr/local/bin/setuidgid qmaill \
  3. /usr/local/bin/multilog t s100000 n20 \
  4. /var/log/qmail/qmail-smtpd \
  5. 2>&1
复制代码

  1. chmod 755 /var/qmail/supervise/qmail-smtpd/run
  2. chmod 755 /var/qmail/supervise/qmail-smtpd/log
  3. chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
复制代码

vi /var/qmail/supervise/qmail-send/run

  1. #!/bin/sh
  2. exec /var/qmail/rc
复制代码

vi /var/qmail/supervise/qmail-send/log/run

  1. #!/bin/sh
  2. exec /usr/local/bin/setuidgid qmaill \
  3. /usr/local/bin/multilog t s100000 n20 \
  4. /var/log/qmail/qmail-send \
  5. 2>&1
复制代码


  1. chmod 755 /var/qmail/supervise/qmail-send/run
  2. chmod 755 /var/qmail/supervise/qmail-send/log
  3. chmod 755 /var/qmail/supervise/qmail-send/log/run
复制代码
[/quote]

Step 8 *Install SpamAssassin*

  1. cd /usr/ports/mail/p5-Mail-SpamAssassin
  2. make install clean
复制代码

[quote]#Options for p5-Mail-SpamAssassin 3.1.6
#deselect Add PostreSQL support

  1. echo 'spamd_enable="YES"' >> /etc/rc.conf
复制代码

  1. cp /usr/local/etc/mail/spamassassin/local.cf.sample /usr/local/etc/mail/spamassassin/local.cf
复制代码


  1. fetch -o /usr/local/share/spamassassin/Chinese_rules.cf http://www.ccert.edu.cn/spam/sa/Chinese_rules.cf
  2. fetch -o /usr/local/share/spamassassin/55_diy_score.cf http://anti-spam.org.cn/rules/sa/55_diy_score.cf
复制代码

# build SpamAssassin learn system
  1. sa-learn --rebuild -D -p user_prefs
复制代码

# check learn result
  1. sa-learn --dump all
复制代码

  1. /usr/local/etc/rc.d/sa-spamd start
复制代码
[/quote]

Step 9 *Create qmail.sh control script*

[quote]vi /var/qmail/qmail.sh

  1. #!/bin/sh
  2. case "$1" in
  3. start)
  4. echo -n "Starting qmail: svscan"
  5. if cd /var/qmail/supervise; then
  6. env - PATH="/var/qmail/bin:$PATH" svscan &
  7. echo $! > /var/run/svscan.pid
  8. fi
  9. echo "."
  10. ;;
  11. stop)
  12. echo -n "Stopping qmail: svscan"
  13. kill -9 `cat /var/run/svscan.pid`
  14. echo -n " qmail"
  15. svc -dx /var/qmail/supervise/*
  16. echo -n " logging"
  17. svc -dx /var/qmail/supervise/*/log
  18. echo "."
  19. ;;
  20. stat)
  21. cd /var/qmail/supervise
  22. svstat * */log
  23. ;;
  24. doqueue|alrm)
  25. echo "Sending ALRM signal to qmail-send."
  26. svc -a /var/qmail/supervise/qmail-send
  27. ;;
  28. queue)
  29. /var/qmail/bin/qmail-qstat
  30. /var/qmail/bin/qmail-qread
  31. ;;
  32. reload|hup)
  33. echo "Sending HUP signal to qmail-send."
  34. svc -h /var/qmail/supervise/qmail-send
  35. echo "Sending HUP signal to qmail-pop3d."
  36. svc -h /var/qmail/supervise/qmail-pop3d
  37. ;;
  38. pause)
  39. echo "Pausing qmail-send"
  40. svc -p /var/qmail/supervise/qmail-send
  41. echo "Pausing qmail-smtpd"
  42. svc -p /var/qmail/supervise/qmail-smtpd
  43. echo "Pausing qmail-pop3d"
  44. svc -p /var/qmail/supervise/qmail-pop3d
  45. ;;
  46. cont)
  47. echo "Continuing qmail-send"
  48. svc -c /var/qmail/supervise/qmail-send
  49. echo "Continuing qmail-smtpd"
复制代码



  1. # cat /var/qmail/control/helohost
  2. mail.levopat.com

  3. # cat /var/qmail/control/queuelifetime
  4. 86400

  5. # cat /var/qmail/control/databytes
  6. 2097152
复制代码



  1. chmod +x /var/qmail/qmail.sh

  2. /var/qmail/qmail.sh cdb

  3. echo 'svscan_enable="YES"' >> /etc/rc.conf
  4. echo 'svscan_servicedir="/service"' >> /etc/rc.conf
  5. /usr/local/etc/rc.d/svscan.sh start


复制代码
[/quote]

* The end *

[ 本帖最后由 levopat 于 2007-4-6 08:50 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-04-05 12:00 |只看该作者
看起来不错的样子

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
3 [报告]
发表于 2007-04-05 12:46 |只看该作者
很不错,很好。

我在学校的时候就这么做过,可惜当时没有留文档,呵呵。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2007-04-05 14:28 |只看该作者
顶一下

论坛徽章:
0
5 [报告]
发表于 2007-04-05 14:41 |只看该作者
有的部分要用鼠标选一下才能显示正常,可能是我的IE问题。

论坛徽章:
0
6 [报告]
发表于 2007-04-05 14:47 |只看该作者
还是Postfix比较正统

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
7 [报告]
发表于 2007-04-05 14:54 |只看该作者
不错,收藏了

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
8 [报告]
发表于 2007-04-05 14:54 |只看该作者
原帖由 Ericzhao82 于 2007-4-5 14:47 发表
还是Postfix比较正统


Qmail不正统?

论坛徽章:
0
9 [报告]
发表于 2007-04-05 20:48 |只看该作者
好文是要顶的

论坛徽章:
0
10 [报告]
发表于 2007-04-06 08:47 |只看该作者
同时发布在: http://www.freebsdchina.org/forum/viewtopic.php?p=190658
以后更新请关注本贴。

[ 本帖最后由 levopat 于 2007-4-6 10:15 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP