Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I configure sendmail to keep a copy of any message I send. An option would be to automatically send a copy back to my box.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

1 Create file ${CFDIR}/mailer/copymail.m4:

PUSHDIVERT(-1)

ifdef(`COPYMAIL_MAILBOX',,
    `define(`COPYMAIL_MAILBOX', `postmaster')')dnl
POPDIVERT

#########################################
###   COPYMAIL Mailer specification   ###
#########################################

VERSIONID(`$Id: cpsendmail.html,v 1.2 2002/06/14 18:39:10 freeman Exp $')dnl

LOCAL_CONFIG
D{COPYMAIL}COPYMAIL
C{CP}${COPYMAIL}

LOCAL_RULE_0
# Send all mail to copymail mailer
R$* < @ $+ . $~{CP} . >     $#copymail $@ $2 . $3 . ${COPYMAIL} $: $1 @ $2 . $3 . ${COPYMAIL}
# if mail has been processed by copymail mailer, process it usual way...
R$* < @ $* . ${COPYMAIL} >  $1 < @ $2 . >

# Send message to original recipient + additional mailbox: COPYMAIL_MAILBOX
Mcopymail, P=/usr/sbin/sendmail, F=fmSDFMu, S=0, R=0,
    A=sendmail -N never COPYMAIL_MAILBOX.${COPYMAIL} $u

2 Add to end sendmail.mc

define(`COPYMAIL_MAILBOX',`user@domen')
MAILER(copymail)

3 Compile and install new sendmail.mc

4 Restart sendmail

5 Testing

share|improve this answer
    
Very good post! Try to add some information in steps 3 to 5 for mightiness –  lynxman Jan 31 '11 at 9:25
add comment

Check syntax as below

ie "TAB HERE"

R$* < @ $+ . $~{CP} . >"**TAB HERE**"$#copymail $@ $2 . $3 . ${COPYMAIL} $: $1 @ $2 . $3 . ${COPYMAIL}
# if mail has been processed by copymail mailer, process it usual way...
R$* < @ $* . ${COPYMAIL} >"**TAB HERE**"$1 < @ $2 . >
share|improve this answer
    
Thanks a lot! This fixed the problem with the other answer. –  M28 Dec 12 '13 at 23:52
    
Since the user that made that answer hasn't logged in 2 years. Could you tell me if the users in that mail server would know that their mail is being sent somewhere else too? Does it appear in the headers? –  M28 Dec 13 '13 at 3:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.