Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to run a process every time sendmail sends an email.

0 views
Skip to first unread message

Oso

unread,
Sep 26, 2008, 4:29:29 PM9/26/08
to
Hi,

I want to know how to run a process every time sendmail sends an
email.

I don't want to process the email content, or addresses, just call a
program (like a counter).

Any ideas?

J.O. Aho

unread,
Sep 26, 2008, 4:54:09 PM9/26/08
to
Oso wrote:

If you want just some mail counter, then use logwatch to check the sendmail
log and you will get a good statistics about howm many mails sent, received,
mail sizes and so on.


--

//Aho

Oso

unread,
Sep 26, 2008, 5:07:54 PM9/26/08
to
Its more than a counter, but I need to run immediately after a mail
has been sent.

Watching logs are the only way to do this?

Grant Taylor

unread,
Sep 26, 2008, 6:12:46 PM9/26/08
to
On 09/26/08 16:07, Oso wrote:
> Its more than a counter, but I need to run immediately after a mail
> has been sent.

Ok...

> Watching logs are the only way to do this?

You might be able to define a new mailer or alter the (e|)smtp mailer(s)
so that they call an external program.

Grant. . . .

David F. Skoll

unread,
Sep 27, 2008, 11:25:24 AM9/27/08
to
Oso wrote:

> I want to know how to run a process every time sendmail sends an
> email.

You could use a milter. This is more efficient than starting a new
process each time.

(Technically, a milter gets called every time Sendmail *receives* a
message via SMTP, but in many situations this is close enough.)

Regards,

David.

Eugene Grosbein

unread,
Oct 6, 2008, 2:58:52 AM10/6/08
to
27 сен 2008, суббота, в 04:29 KRAT, Oso написал(а):

O> I want to know how to run a process every time sendmail sends an
O> email.
O> I don't want to process the email content, or addresses, just call a
O> program (like a counter).

In Unix environment, I use syslog's ability to feed a program or script
with copies of log records written by sendmail. It works just fine,
in syslog.conf I have:

mail.info /var/log/maillog
mail.* |/usr/local/adm/script

So, script obtains every line sendmail writes to the log, so processing
may be as simple as:

#!/bin/sh
# script - /usr/local/adm/script
while read line
do
case "$line" in
*stat=Sent) ... ;; # here you may do what you wish, run a process etc.
esac
done
#EOF

Eugene

0 new messages