2011/11/25 Wietse Venema <wie...@porcupine.org>:
> Vincenzo Romano:
>> 2011/11/25 Ralf Hildebrandt <ralf.hildebra...@charite.de>:
>> > * Vincenzo Romano <vincenzo.rom...@notorand.it>:
>> >> Hi all.
>> >> My application uses the sendmail interface of its local postfix
>> >> installation to send emails, a few thousand a day.
>> >> Of course, this has been working pretty fine so far.
>> >> Now I'd need to be able to track these emails and the best thing I
>> >> could do is to "somehow" obtain from sendmail/postfix
>> >> the message-ID it generated to each single submission so I can later
>> >> check the logs about delays and so on.
>> >> I've not been able to find a reliable way to do it as my issue is that
>> >> I can send several emails to the same destination address within a few
>> >> seconds and simply use the destination address and the (supposed)
>> >> submission timestamp won't help much.
>> >> Any idea whether this is doable and how to?
>> >
>> > Rather use SMTP injection and then use the queueid:
>> >
>> > MAIL FROM:<hil...@charite.de>
>> > 250 2.1.0 Ok
>> > RCPT TO:<vincenzo.rom...@notorand.it>
>> > 250 2.1.5 Ok
>> > DATA
>> > 354 End data with <CR><LF>.<CR><LF>
>> > foo
>> > .
>> > 250 2.0.0 Ok: queued as 3Sqgph2ghTz2r0b   <-------- !
>> > QUIT
>> >
>>
>> Yes, that's the SMTP dialogue.
>> But it seems to me that the sendmail (or any other postfix tool) can
>> provide it to be on a per-submission basis ...
>
> The Postfix sendmail command creates a temporary queue file that
> is deleted as soon as the local mail pickup daemon has read the
> file. So, that queue file ID is useless.
>
> You can specify your own envelope ID on the Postfix sendmail command
> line. This will be returned in delivery status notifications (as
> long as the remote MTA implements the DSN RFCs).
>
> Postfix does not log the DSN envelope ID information, but code for
> that could be added to the cleanup daemon.
>
> There is also RFC 3885 which builds a tracking mechanism on top of
> the aforementioned DSN envelope ID information. But this is of limited
> interest, since qmail, exim and some other MTAs don't implement DSN.

Thanks Wietse (also for the honor).
Maybe I've been not clear enough and I apologyze for that.
I'll try to describe a real life case.
Once I do the submission with sendmail tool, I need to check on my
machine whether the message actually left the system for the delivery
(which can access the Internet) or if it got queued or trashed for
some reason.
As far as I remember I can link the various lines in the log only
thanks to the queue ID.
This is what I do, step by step, within the logs:

0. First restrict the search field to a "reasonable" time period in
the logs. Usually one day.

1. I look for "postfix/qmgr" and the destination email address to
extract che queue ID (something like 42DF66C96E).

2. I look then for both that queue ID and "postfix/smtp" in order to
extract the status (something like "status=sent") and the remote SMTP
response (something like "(250 2.0.0 OK 1322295987
b11si12544560fak.190)" ).

3. I look then for both that queue ID and "postfix/cleanup" in order
to extract the local message-ID (something like
"message-id=<20111126082624.42DF66C96E@system.domain>")

The step #2 is needed in order to know whether the message actually
left the system (status=sent) or bounced or got deferred. I can also
get the actual response from the remore server.
Steps #2 and #3 are needed in order to be able to look for the message
on either side.

The steps #0 and #1 are approximate, especially when I send several
distinct messages in the same second to the same destination. Which
can easily happen.
I understood that I cannot grab the local message ID straight from
sendmail, this is why I focused on the queue ID.

But, is it possible to know the queue ID from the sendmail tool (or
whatever other submission tool) to be reasonably precise on the
subsequent email tracking lookups?

Reply via email to