[Dovecot] How to log uid and keywords of delivered mail?
Ron Avriel
ravriel_1 at yahoo.com
Wed Feb 13 08:53:49 EET 2008
Hi,
I’d like to extend the mail_log plugin to log the uid and keywords of a mail delivered by LDA. The keywords are set by the sieve plugin.
I added a mail_log_save_finish() function hook listed below.
However, the uid of the mail is always zero and trying to get the keywords results in assertion failure, probably because the message is not committed yet:
Feb 13 08:07:42 ha-test1 deliver(test1 at example.com): dest mail seq: 23, uid: 0
Feb 13 08:07:42 ha-test1 deliver(test1 at example.com): file mail-index-view.c: line 217 (_view_lookup_full): assertion failed: (seq > 0 && seq <= mail_index_view_get_messages_count(view))
Feb 13 08:07:42 ha-test1 deliver(test1 at example.com): Raw backtrace: /usr/local/libexec/dovecot/deliver(i_syslog_panic_handler+0x21) [0x80965d9] -> /usr/local/libexec/dovecot/deliver [0x8096443] -> /usr/local/libexec/dovecot/deliver [0x80821d0] -> /usr/local/libexec/dovecot/deliver [0x80827c3] -> /usr/local/libexec/dovecot/deliver(mail_index_lookup_keywords+0x32) [0x8082aae] -> /usr/local/libexec/dovecot/deliver(index_mail_get_keywords+0x6c) [0x806f038] -> /usr/local/lib/dovecot/lda/lib20_mail_log_plugin.so [0xcbdac8] -> /usr/local/libexec/dovecot/deliver(mail_storage_copy+0xa8) [0x808a600] -> /usr/local/libexec/dovecot/deliver(maildir_copy+0x3e) [0x805e252] -> /usr/local/lib/dovecot/lda/lib10_quota_plugin.so [0xfc9741] -> /usr/local/lib/dovecot/lda/lib20_mail_log_plugin.so [0xcbd48f] -> /usr/local/libexec/dovecot/deliver(deliver_save+0x192) [0x80559ea] -> /usr/local/lib/dovecot/lda/lib90_cmusieve_plugin.so [0xaa16bf] ->
/usr/local/lib/dovecot/lda/lib90_cmusieve_plugin.so [0xaaea0d] -> /usr/local/lib/dovecot/lda/lib9
static int mail_log_save_finish(struct mail_save_context *ctx,
struct mail *dest_mail)
{
struct mail_log_mailbox *lbox = MAIL_LOG_CONTEXT(ctx->transaction->box);
int ret;
ret = lbox->super.save_finish(ctx, dest_mail);
if (ret < 0) {
return ret;
}
if (dest_mail != NULL) {
const char *const *kw_list;
i_info("dest mail seq: %u, uid: %u", dest_mail->seq, dest_mail->uid);
kw_list = mail_get_keywords(dest_mail);
i_info("dest mail kw: %s", kw_list ? t_strarray_join(kw_list, ",") : "NONE");
}
return ret;
}
Some mail data, such as flags and headers, can be retrieved OK.
I'm using dovecot-1.0.10 and dovecot-sieve-1.0.2.
Any help in getting the uid and keywords by mail_log plugin will be
greatly appreciated.
Thanks,
Ron
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the dovecot
mailing list