From: ram on

On Mon, 2010-02-22 at 07:13 -0500, Wietse Venema wrote:
> ram:
> >
> > On Sat, 2010-02-20 at 14:30 -0500, Victor Duchovni wrote:
> > > On Sat, Feb 20, 2010 at 03:43:25PM +0530, ram wrote:
> > >
> > > > One of our clients sends contract notes to their customers and they
> > > > require to store all logs of deliveries/bounces by some law.
> > > >
> > > > They have requirements like
> > > >
> > > > * The log should contain the full date including year
> > > > * The log line should indicate full info -->
> > > > sender,rcpt,datetime,size,status
> > > >
> > > > I have managed to add custom logs in postfix source in bounce.c and
> > > > sent.c. (Thanks to the neatly structured code it wasnt much of an
> > > > effort)
> > > >
> > > >
> > > > Only problem is when a message expires there is no log line that says
> > > > $queue-id: "$sender" to "$rcpt" status=expired
> > > >
> > > > How can I log this ?
> > >
> > > Collate the logs by message-id. What expired is the message, therefore,
> > > all recipients not yet delivered are expired.
> > >
> > But when a message expires , the recipient not delivered is not logged
> > at all.( Except for in status=deferred lines much much before the
> > expiry )
> > Collating lines from different places in the logfile calls for some
> > parsing. The parser may in itself be very trivial but I have to educate
> > the client to read "collated" :-(
> >
> > > If the client uses a decently written bounce-bot, they can parse any
> > > bounces and extract the undelivered recipients.
> > >
> >
> > Perfect.
> > We are already doing bounce handling at the bounce box.
> > The real requirement here is just cosmetic: "We need logs of every
> > single mail with *exact* status for 7 years"
>
> Record "status=deferred" just like "status=bounced" or "status=sent",
> and when a message expires, use the last "status=deferred" information.
>
Thats a painful workaround. :-( Writing a clean log parser especially
when your logs can get rotated anytime in between.


I was hoping for being able to insert a syslog of "rcpt=<$rcpt>
status=<expired>" in the code.
All these mails are single recipient mails.

Nevertheless , There has been a learning for me. Not to accept weird
requirements.


Thanks a lot anyway
Ram

From: Wietse Venema on
ram:
> > Record "status=deferred" just like "status=bounced" or "status=sent",
> > and when a message expires, use the last "status=deferred" information.
> >
> Thats a painful workaround. :-( Writing a clean log parser especially
> when your logs can get rotated anytime in between.

For the next time that someone wants to do this:

1) Process the logfile records while they are written, for
example, using the pipe-to-command option of syslogd.

2) Store the "status=sent/bounced/deferred" of ALL RECIPIENTS
together with the unique transaction ID for the email message.

3) Store a record when a message is expired/deleted, together with
the unique transaction ID for the email message.

Then, all recipients with "status=deferred" and whose unique
transaction ID has a status of expired/deleted, are bounced. The
other "status=deferred" recipients are still in progress.

Wietse