Mailing List Archive

Qmail-command gets message Id Numbers?
Folks:

I'm trying to write a program that will handle incoming mail using the
qmail-command mechanism. Actually, I've got this program written, and it
works great, but I've got one difficulty.

I'd like to use syslog(3) to log the work done by my qmail-command program.
This is easy enough to do, but there's one problem: I can't correlate the
messages that I'm adding with those that are added by qmail, in order to tie
the log entries to specific mail messages.

Ideally, I'd like to have some way to tell my qmail-command program the ID
number of the message that I'm currently processing, but I can't see anyway to
do that. In particular, it doesn't seem to be one the env. variables provided
to the qmail-command program.

So, does anyone know how I might get a hold of this id number? Failing that,
any alternative work-around solutions?

BTW: Thanks Dan, for some great work.

-Harry Hochheiser

--
Harry Hochheiser harry@tigger.jvnc.net
PGP key fingerprint:
08 3A B5 F6 47 7F C7 C4 28 B4 8D D2 2E DF F6 1E
Re: Qmail-command gets message Id Numbers? [ In reply to ]
[ Harry Hochheiser <harry@tigger.jvnc.net> 1997-3 -24 11:54 -0500 ]
|---
|
| Folks:
|
| I'm trying to write a program that will handle incoming mail using the
| qmail-command mechanism. Actually, I've got this program written, and
| it works great, but I've got one difficulty.
|
| I'd like to use syslog(3) to log the work done by my qmail-command
| program. This is easy enough to do, but there's one problem: I
| can't correlate the messages that I'm adding with those that are
| added by qmail, in order to tie the log entries to specific mail
| messages.

Just let your qmail-command program write to stdout, and qmail-send
will get hold of the output and put it in the log for you.

If you really really want the queue id of the mail message, it will be
the inode number of the file on stdin. But this number is unique for
your message only for the lifetime of the message in the queue, so it
is of limited usefulness in identifying the message. (On my own
machine, I often see the same number being reused for several
consecutive messages. This will probably be the typical behaviour
when there is little mail activity and not a lot is happening on the
file system containing the queue.)

- Harald
Re: Qmail-command gets message Id Numbers? [ In reply to ]
>Folks:
>
>I'm trying to write a program that will handle incoming mail using the
>qmail-command mechanism. Actually, I've got this program written, and it
>works great, but I've got one difficulty.
>
>I'd like to use syslog(3) to log the work done by my qmail-command program.
>This is easy enough to do, but there's one problem: I can't correlate the
>messages that I'm adding with those that are added by qmail, in order to tie
>the log entries to specific mail messages.
>
>Ideally, I'd like to have some way to tell my qmail-command program the ID
>number of the message that I'm currently processing, but I can't see anyway to
>do that. In particular, it doesn't seem to be one the env. variables provided
>to the qmail-command program.
>
>So, does anyone know how I might get a hold of this id number? Failing that,
>any alternative work-around solutions?

You're not going to have any fun, because there is no guarantee
that an incoming message has a message ID. Qmail-inject does
perform an explicit check for a message ID, as it will create one
as necessary, but qmail-smtpd does not perform the same check,
and will allow a message with no ID into the queue. This does not
affect delivery, though.

I think qmail-command gets invoked by qmail-spawn, and it has no
knowledge of the contents of the headers ( that I can think of ).
It only knows messages and envelopes.

I've written some tools that try to correlate qid/did/message/timestamps
together, but it's a bit fuzzy, as you actually have several
programs doing logging on their own, and they have no knowledge of
each other's environment.

>
> BTW: Thanks Dan, for some great work.

I, despite my bitching, am impressed, too. It's lean and mean,
and does the job.

>
> -Harry Hochheiser
>
> --
> Harry Hochheiser harry@tigger.jvnc.net
> PGP key fingerprint:
> 08 3A B5 F6 47 7F C7 C4 28 B4 8D D2 2E DF F6 1E
>

--
Brian Reichert The Internet Company
617-547-3600 x161 96 Sherman Street
reichert@internet.com Cambridge, MA 02140
Re: Qmail-command gets message Id Numbers? [ In reply to ]
On Tue, 25 Mar 1997, Mark Delany wrote:

> : Received: (qmail 15438 invoked by uid 999); 24 Mar 1997 17:33:56 -0000
>
> This represents qp 15438 which is unique per invocation of qmail-send.
>
> No environment variable is set that represents this information and it also
> means you have to parse the contents of the mail.

hmm, does the queueing mechanism provide this to qmail-inject/qmail-smtpd?

\w0zz
Re: Qmail-command gets message Id Numbers? [ In reply to ]
[ Mark Delany <markd@mira.net.au> 1997-3 -25 4:33 -1000 ]
|---
| : Received: (qmail 15438 invoked by uid 999); 24 Mar 1997 17:33:56 -0000
|
| This represents qp 15438 which is unique per invocation of qmail-send.

Er, actually the qp is the pid of the instance of qmail-queue that put the
message in the queue. So it's only unique until the pids wrap around.
But of course that is usually much longer than the inode number derived
queue id, which typically gets reused all the time.

- Harald
Re: Qmail-command gets message Id Numbers? [ In reply to ]
At 12:32 PM 3/24/97 -0500, Brian Reichert wrote:
>>Folks:
>>
>>I'm trying to write a program that will handle incoming mail using the
>>qmail-command mechanism. Actually, I've got this program written, and it
>>works great, but I've got one difficulty.
>>
>>I'd like to use syslog(3) to log the work done by my qmail-command
program.
>>This is easy enough to do, but there's one problem: I can't correlate the
>>messages that I'm adding with those that are added by qmail, in order to
tie
>>the log entries to specific mail messages.
>>
>>Ideally, I'd like to have some way to tell my qmail-command program the ID
>>number of the message that I'm currently processing, but I can't see
anyway to
>>do that. In particular, it doesn't seem to be one the env. variables
provided
>>to the qmail-command program.
>>
>>So, does anyone know how I might get a hold of this id number? Failing
that,
>>any alternative work-around solutions?
>
>You're not going to have any fun, because there is no guarantee
>that an incoming message has a message ID. Qmail-inject does

I believe that if you look at the last Received: line generated (that is,
the first one in the headers) you will find the qp number. Eg:

: Received: (qmail 15438 invoked by uid 999); 24 Mar 1997 17:33:56 -0000

This represents qp 15438 which is unique per invocation of qmail-send.

No environment variable is set that represents this information and it also
means you have to parse the contents of the mail.


Regards.