royong
07-05-2007, 15:35
Setup a COPYUSER such that all emails are archived to the COPYUSER account
Originally from http://www.geocities.com/sbmilbur/sendmail/
First, we create the appropriate user account and assign it with a default password
# useradd copyuser
# echo "123456" | passwd --stdin copyuser
Next, we setup the additional ruleset
# cat > /usr/share/sendmail-cf/feature/msgidruleset.m4 <<"EOF"
VERSIONID(`msgidruleset.m4')
VERSIONID(`and any sendmail.cf files created using thie M4 macro file')
VERSIONID(`Modified to handle logging local mail as well as external mail')
ifdef(`_MAILER_smtp_',,
`errprint(`*** MAILER(smtp) must appear before copymail mailer')')dnl
LOCAL_CONFIG
CPNOCOPY
LOCAL_NET_CONFIG
LOCAL_RULE_0
R$+.NOCOPY. $#local @ $: $1
R$+<@$j.NOCOPY.> $#local @ $: $1
R$+<@$+.NOCOPY.> $#esmtp $@$2 $:$1<@$2.>
R$+<@$+.> $#copymail $@nohostneeded $:$1<@$2.NOCOPY>
R$+<@$+> $#copymail $@nohostneeded $:$1<@$2.NOCOPY>
R$+ $#copymail $@nohostneeded $:$1<@$j.NOCOPY>
MAILER_DEFINITIONS
# Copy a message by sending it back to sendmail with an
# additional adress: "original To:" + copyuser
Mcopymail, P=/usr/lib/sendmail, F=mDFMuX, S=11/31, R=21, E=\r\n, L=990,
T=DNS/RFC822/X-Unix,
A=/usr/lib/sendmail -oi copyuser@$j.NOCOPY $u
EOF
Backup a copy of your original sendmail configuration files
# cp -a /etc/mail/sendmail.cf /etc/mail/sendmail.cf.backup
# cp -a /etc/mail/sendmail.mc /etc/mail/sendmail.mc.backup
Adding in the ruleset to the sendmail configuration files
# echo "FEATURE(msgidruleset)" >> /etc/mail/sendmail.mc
# m4 sendmail.mc > sendmail.cf
Restarting the sendmail service
# service sendmail restart
Additional Notes
When you are doing m4 sendmail.mc > sendmail.cf
there might be an error warning you about having
the "FEATURE(msgidruleset)" right at the end of the file.
Ignore the error, it will work fine
Originally from http://www.geocities.com/sbmilbur/sendmail/
First, we create the appropriate user account and assign it with a default password
# useradd copyuser
# echo "123456" | passwd --stdin copyuser
Next, we setup the additional ruleset
# cat > /usr/share/sendmail-cf/feature/msgidruleset.m4 <<"EOF"
VERSIONID(`msgidruleset.m4')
VERSIONID(`and any sendmail.cf files created using thie M4 macro file')
VERSIONID(`Modified to handle logging local mail as well as external mail')
ifdef(`_MAILER_smtp_',,
`errprint(`*** MAILER(smtp) must appear before copymail mailer')')dnl
LOCAL_CONFIG
CPNOCOPY
LOCAL_NET_CONFIG
LOCAL_RULE_0
R$+.NOCOPY. $#local @ $: $1
R$+<@$j.NOCOPY.> $#local @ $: $1
R$+<@$+.NOCOPY.> $#esmtp $@$2 $:$1<@$2.>
R$+<@$+.> $#copymail $@nohostneeded $:$1<@$2.NOCOPY>
R$+<@$+> $#copymail $@nohostneeded $:$1<@$2.NOCOPY>
R$+ $#copymail $@nohostneeded $:$1<@$j.NOCOPY>
MAILER_DEFINITIONS
# Copy a message by sending it back to sendmail with an
# additional adress: "original To:" + copyuser
Mcopymail, P=/usr/lib/sendmail, F=mDFMuX, S=11/31, R=21, E=\r\n, L=990,
T=DNS/RFC822/X-Unix,
A=/usr/lib/sendmail -oi copyuser@$j.NOCOPY $u
EOF
Backup a copy of your original sendmail configuration files
# cp -a /etc/mail/sendmail.cf /etc/mail/sendmail.cf.backup
# cp -a /etc/mail/sendmail.mc /etc/mail/sendmail.mc.backup
Adding in the ruleset to the sendmail configuration files
# echo "FEATURE(msgidruleset)" >> /etc/mail/sendmail.mc
# m4 sendmail.mc > sendmail.cf
Restarting the sendmail service
# service sendmail restart
Additional Notes
When you are doing m4 sendmail.mc > sendmail.cf
there might be an error warning you about having
the "FEATURE(msgidruleset)" right at the end of the file.
Ignore the error, it will work fine