51CTO技术论坛 » Mail服务器 » [原创]如何使用sendmail+procmail备份所有发出和收入的邮件?        上一帖     下一帖    查看完整版本

页: [1]

wantin62006-8-10 04:57
[原创]如何使用sendmail+procmail备份所有发出和收入的邮件?

*****************************************************
Disclaimer:

The author of this post takes absolutely NO responsbility for any risks and voliations involving in anyway using this post.   Be warned that eavesdropping emails is a serious crime.

Please keep above disclaimer intact when posting it in other forums.  Thank you!

*****************************************************

Making an automatic copy of all inbound emails

*Create /etc/procmailrc PMDIR=/etc/procmail

   LOGFILE=/var/log/pmlog
   VERBOSE=yes # Set to yes when debugging; default is no
   INCLUDERC=$PMDIR/rc.localcopy

*Create directory (files) and change permission (presume sendmail is running as root)

   chmod 400 /etc/procmailrc
   mkdir /etc/procmail
   chmod 700 /etc/procmail
   chmod 600 /etc/procmail/*
   touch /var/log/pmlog
   chmod 600 /var/log/pmlog

*Create /etc/procmail/rc.localcopy as follow:

   :0c
   ! [url=mailto:postmaster@mydomain.com]postmaster@mydomain.com[/url] # each messages will be forwarded to postmaster


Making an automatic copy of all outbound emails (tested in Redhat 8.0)

*Create /usr/share/sendmail-cf/cf/sendmail.mc (add the following line).

LOCAL_CONFIG
CP PROCMAIL
LOCAL_RULE_0
R$*;$: ; $1
R; $+ ;;$: $>;canonify $1 @ $2
R; $+ ;;$: ; $1 ;
R; $+ ; $#procmail $@ /etc/procmail/procsh;$: $1 ;
R; $*;$: $1
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

*Replacing all ; with real TAB and ./Build sendmail.cf.
*cp /usr/share/sendmail-cf/cf/sendmail.cf /etc/mail/sendmail.cf
*/etc/init.d/sendmail restart

* Create /etc/procmail/procsh as in sendmail.cf as:     

   PMDIR=/etc/procmail
   LOGFILE=/var/log/pmlog
   VERBOSE=yes
   :0
   * !^To:.*@yourdomain.com # for any emails sending out (not local domain)
   {
   :0c:
   /var/mail/outbound # make a copy
   }
   :0
   ! -f "$@" # send message back to sendmail for handling

*chmod 400 /etc/procmail/procsh
   
* Make sure procsh is different from /etc/procmailrc because /etc/procmailrc is system level rc file for procmail. It could be used for CC inbound emails. Don't mix them together.


NOTES: By setting sendmail to use procmail as LDA (local delivery agent) in order to make a copy of all outbound emails, this sendmail server lose the ability to receive inbound emails.  So far, I have not figured out how to solve this issue in sendmail.  If you have any idea, please post it to this forum.

A work around is seperating inbound & outbound email servers, such as setting up an outbound email gateway (which is not uncommon), and using the standard sendmail configuration for inbound emails.  Another option is using 2 sendmail binaries in this server, one for outbound and another for inbound, but it needs to be tested.


  

关键词: 备份       sendmail       邮件       Cmail       cma       

相关文章:
Linux下Sendmail邮件服务器转发功能的讲解
即时备份/瞬间容灾恢复技术(1)
谁有好的邮件服务器软件.可以给我传几个破解版本的吗?
黑客攻击电子邮件系统方法及防护措施
数据库自动备份到其他SQL服务器的说明电子书

查看完整版本: [原创]如何使用sendmail+procmail备份所有发出和收入的邮件?


Powered by 51CTO.COM