LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Need sendmail rule for copying relayed, nonlocal mail (http://www.linuxquestions.org/questions/linux-server-73/need-sendmail-rule-for-copying-relayed-nonlocal-mail-4175457425/)

mfoley 04-08-2013 06:14 PM

Need sendmail rule for copying relayed, nonlocal mail
 
I need advice from a serious sendmail guru who knows about rules.

I am using sendmail 8.14.4 on Linux Slackware distro 13.37.0, kernel version 2.6.37.6. I am trying to set up sendmail to copy all non-local emails to be delivered to the smarthost to a specific mailbox for spam analysis.

Following the sparse, but workable instructions at: http://serverfault.com/questions/229...tgoing-message

I created the following M4 file in /usr/share/sendmail/cf/mailer/copymail.cf

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

and added the following lines to my sendmail.mc file:

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

This worked beautifully ... but for locally delivered mail only! I don't care about archiving local mail, I only want mail which is sent on to the SmartHost.

I don't really understand how to make rules in sendmail. I just monkey-typed the copymail.m4 file shown above. Is there anyone with some knowledge of sendmail rules who could give me instructions on how to modify the copymail.m4 rules to copy only mail sent to the smarthost?

Thanks - in need!

mfoley 04-09-2013 03:06 PM

Not to be impatient, but my boss is all over me to get some analysis going ...

Surely there are some sendmail Yoda's out there?

Pseudo-codely, what I need is:

if recipient is "@thisdomain.com" or forwarding to smarthost // can be either condition, whichever is easier, don't need both
then
send copy of email to mbox[@myhost.com]
endif

Easy for someone familiar with sendmail rule making, right? (too bad sendmail syntax sucks so bad! I've got a book, but I'm not clever or patient enough)

Is there a sendmail rule generator app out there that can accept such pseudo code?

I need help! Soon!


All times are GMT -5. The time now is 12:16 PM.