LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 08-06-2010, 12:11 PM   #1
thope
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Rep: Reputation: 0
sendmail subject logging


I am looking for the syntax for a sendmail ruleset to log the message subject to the syslog service. I have found a few posts on the web, but none seem to work. The basic appear to be - add the following to the sendmail.mc file then compile the sendmail.cf file using M4. The syntax suggested follows (I believe the rewrite rule is incorrect)(I and using <T> to indicate tabs):

LOCAL_CONFIC
Klog syslog
HSubject:<T>$>Check_Subject

LOCAL_RULESETS
SCheck_Subject
R$*<T>$:<T>$(log Subject=$1<T>$)<T>$1

sendmail.cf compiles and when used as the config file for sendmail - everything appears to work, but no subject is logged.

any suggestions would be greatly appreciated.
Thanks to all.
 
Old 08-06-2010, 04:12 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Hi,

Take a look at the 2nd post here

BTW, the only <Tab> you need is in the ruleset, after the R$*. Check sendmail.cf if it is preserved.
Code:
LOCAL_CONFIG
Klog syslog
HSubject: $>+CheckSubject

LOCAL_RULESETS
SCheckSubject
R$*<Tab>$: $(log Subject: $1 $) $1
Regards
 
1 members found this post helpful.
Old 08-06-2010, 06:08 PM   #3
thope
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks bathory

The post you referenced was one of the spots I found and tried. Must either be a typo or some other config issue. I am using slackerware 13 running sendmail version 8.14.3. I have retyped the lines into my .mc file (made a copy of the sendmail-slackware.mc file under /usr/share/sendmail/cf/cf called sendmail-slackware-subject-logging.mc. I then run the M4 compiler using the command line:
m4 sendmail-slackware-subject-logging.mc >sendmail-slackware-sunject-logging.cf
After compiling with no warnings or errors, copy the .cf file to /etc/mail/ (original was renamed to preserve it)
I then cd to /etc/mail and copy the sendmail-slackware-subject-logging.cf to sendmail.cf then restart sendmail.
when I send a test message, the message gets delivered - but no subject is logged to /var/log/maillog

Am I doing something in the wrong order?
could I have missed some prerequisite set related to syslog levels?

Thanks for the quick response,
Terry
 
Old 08-07-2010, 03:48 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Hi,

I'm also using Slackware (it's 13.1 and sendmail version is 8.14.4, but I guess it doesn't matter). I've tested both variations in that post and they both work.
Just note that you have to add the code at the end of the .mc file (I'm using sendmail-slackware-tls-sasl.mc where there is already a LOCAL_CONFIG for ssl), after the MAILER definitions.

Regards
 
Old 08-09-2010, 02:55 PM   #5
thope
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Original Poster
Rep: Reputation: 0
I am attaching the .mc file in case anyone can see an error.

Does anyuone have a breakdown of the rewrite rule and how it is parsed?
Attached Files
File Type: txt sendmail-slackware-subject-logging.mc.txt (2.2 KB, 20 views)
 
Old 08-09-2010, 03:58 PM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
FYI, your .mc works also here.

Quote:
Does anyuone have a breakdown of the rewrite rule and how it is parsed?
I guess you mean where it's written in sendmail.cf. If that's the case, then using your .mc, I have in the resulting sendmail.cf:
starting from line 171:
Code:
Klog syslog
HSubject: $>+CheckSubject


# Configuration version number
DZ8.14.4
and from line 1706
Code:
SCheckSubject
R$*     $: $(log Subject: $1 $) $1
#^L
######################################################################
######################################################################
#####
#####                   MAIL FILTER DEFINITIONS
#####
######################################################################
######################################################################
 
Old 08-09-2010, 04:14 PM   #7
thope
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks bathory

When asking about the breakdown of the rewrite rule - I should have been more clear. I was hoping for explanations of both the RHS and LHS of the rewrite rule.

I took a stab at moving the line with the HSubject:... down below the LOCAL_RULESETS line and now it logs the subject in the /var/log/maillog file as expected.

Thanks for all the assistance. Hope I wasn't too big a pain in the @$$!

Terry
 
Old 08-09-2010, 04:27 PM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
No worries.
Glad to see you've made it

Cheers
 
  


Reply


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
Logging mail subject headers in Postfix timjames Linux - Software 1 03-20-2009 02:07 PM
sendmail subject configuration yusufs Linux - General 8 12-06-2007 03:29 AM
sendmail subject via script ryedunn Linux - Newbie 3 01-08-2005 12:11 PM
subject parameter for sendmail? pwtct Linux - Software 4 08-06-2004 10:58 AM
sendmail (dont just ignore it 'cause its got sendmail in the subject :P) GnomeKing Linux - Networking 1 11-12-2001 09:57 PM


All times are GMT -5. The time now is 08:03 AM.

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