LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-08-2013, 06:14 PM   #1
mfoley
Member
 
Registered: Oct 2008
Posts: 67

Rep: Reputation: 15
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!
 
Old 04-09-2013, 03:06 PM   #2
mfoley
Member
 
Registered: Oct 2008
Posts: 67

Original Poster
Rep: Reputation: 15
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!
 
  


Reply

Tags
sendmail


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changes to a relayed email using sendmail mason188 Linux - Networking 4 07-02-2012 03:17 PM
How to create rule in sendmail for a copy of sending mail?? er_gaurav22 Linux - Server 1 10-09-2007 12:11 PM
sendmail.cf mail rule written language lasantha Linux - Networking 4 02-27-2007 12:10 AM
Problem sending nonlocal mails in sendmail s1mpl1c1ty Linux - Newbie 4 08-29-2005 02:57 AM
can't recieve nonlocal mail Caine101022 Linux - Newbie 1 03-18-2004 05:21 PM


All times are GMT -5. The time now is 03:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration