[Dovecot] How to log uid and keywords of delivered mail?
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@example.com): dest mail seq: 23, uid: 0 Feb 13 08:07:42 ha-test1 deliver(test1@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@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
On Tue, 2008-02-12 at 22:53 -0800, Ron Avriel wrote:
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
Right, because the UIDs are assigned only when committing the transaction. With v1.1 the UIDs are returned:
int mailbox_transaction_commit_get_uids(struct mailbox_transaction_context **t, uint32_t *uid_validity_r, uint32_t *first_saved_uid_r, uint32_t *last_saved_uid_r);
I don't think there's an easy way to get them with v1.0.
and trying to get the keywords results in assertion failure, probably because the message is not committed yet:
If this still happens with v1.1 I could take a look at fixing it..
participants (2)
-
Ron Avriel
-
Timo Sirainen