>I'm wondering the best place/way to log details about each email to a
>database of some sort.
>Specifically I need to log, from address, to address, and email size.
>
>Any hints on where to start?


    Start with the following FAQ entry:

] How do I keep a copy of all incoming and outgoing mail messages?
]
] Answer: Set QUEUE_EXTRA to "Tlog\0" and QUEUE_EXTRALEN to 5 in
] extra.h. Recompile qmail. Put ./msg-log into ~alias/.qmail-log.
]
] You can also use QUEUE_EXTRA to, e.g., record the Message-ID of
] every message: run
]
]    | awk '/^$/ { exit } /^[mM][eE][sS][sS][aA][gG][eE]-/ { print }'
] from ~alias/.qmail-log.

    Instead of piping through awk, for example, you could write a perl
script which scans the message to get the appropriate info and then inserts
that info into a database.

    Alternately, you can just use QUEUE_EXTRA to log full mail messages to a
file, and have a script process it once an (hour, day, week, whatever).
This is much more wasteful of disk space, but if your "database" doesn't
like multiple concurrent access, it's a quick fix.


    Finally, the information you ask for may also be represented by the mail
logs (although it will be envelope from/to, not header from/to).  If that
works for you, then they're already ripe for the picking with the right
script.

    Good luck!

Reply via email to