how to setup the way procmail is logging
Asked Answered
G

1

6

right now in the non verbose log procmail is not logging who the recipient is. It is just logging who the sender is, the subject, date and the delivery.

From [email protected]  Tue Apr 15 20:33:19 2014
 Subject: ***** SPAM 7.3 ***** Foto
  Folder: /usr/lib/dovecot/deliver -d christian -m Junk                  132417

Where can I configure to include the To and the CC into the logfile ?

Galilee answered 15/4, 2014 at 20:42 Comment(1)
See also iki.fi/era/procmail/quickref.htmlWhin
W
7

You simply assign the strings you want to log to the LOG pseudo-variable.

Usually you want to add a newline explicitly. Something like this:

NL="
"
TO=`formail -zxTo:`
Cc=`formail -zxCc:`
LOG=" To: $TO$NL Cc: $CC$NL"

These will usually end up before the "log abstract" (what you have in your question). If you need full control over what gets logged, maybe set LOGABSTRACT=no and implement your own log abstract instead. (This is fairly tricky, though.)

Note also that logging could be asynchronous. The log abstract gets written all at once, but if you have many messages arriving at roughly the same time, you might want to add disambiguating information to the log entries, or (in desperation) force locking during logging so that no two messages can perform logging at the same time.

LOCKFILE=procmail.lock
# Critical section -- only one Procmail instance at a time can execute these recipes
LOG="fnord$NL"
:0w
| /usr/lib/dovecot/deliver -d "$USER" -m "$FOLDER"
# End critical section; release lock
LOCKFILE=

The disambiguating information could be just the process ID. In order to include it in the log abstract also, you need to smuggle it in somehow. Not sure how to do that with Dovecot, is there an option you can pass in which will simply be ignored but logged by Procmail?

TO=`formail -zxTo:`
LOG="[$$] To: $TO$NL"
CC=`formail -zxCc:`
LOG="[$$] Cc: $CC$NL"
:
:
# deliver
:0w
| deliver -d "$USER" -m "$FOLDER" -o ignore=$$

... should end up logging something like Folder: deliver -d you -m INBOX -o ignore=1742 where 1742 would be the process-ID so that you can find the same PID in the previous log entries.

Whin answered 16/4, 2014 at 7:50 Comment(1)
I suppose locking is slowing down procmail. I need to test that. I am going to test LOGABSTRACT=no and include own one ;) thanksGalilee

© 2022 - 2024 — McMap. All rights reserved.