Hello, Paul.

PJS> Looks almost finished enough for svn-trunk. If it works out there it is of
PJS> course very much elligible for 2.0.6. This is a great new feature.

What do you think of another feature, allowing to get all the mail by
POP3? Not only INBOX...
(or only from chosen mailboxes, or even make it tunable in database,
for example, as a field `pop3` in dbmail_mailboxes)

I've done this for myself as a temporary solution: I've changed a bit
the function db_createsession in db.c.
I decided to do minimal changes so that I could also get the contents
of Spam folder by POP3.
I added
u64_t spam_mailbox_idnr;
and made it db_findmailbox("Spam", user_idnr, &spam_mailbox_idnr)

Then I've changed the query just a bit:
WHERE ( msg.mailbox_idnr = '%llu' OR msg.mailbox_idnr = '%llu' )

here the second %llu is the spam_mailbox_idnr.


This way, I get the mail from INBOX and from Spam folder by POP3.
I always use The Bat! (with POP3 for now) at work and I sort the mail
by the presense of header X-Spam-Flag.

Here's the part of the code with my changes in case if anyone would
also like to try this ;)

        u64_t inbox_mailbox_idnr;
        u64_t spam_mailbox_idnr;

        list_init(&session_ptr->messagelst);

        if (db_findmailbox("INBOX", user_idnr, &inbox_mailbox_idnr) <= 0) {
                trace(TRACE_ERROR, "%s,%s: error finding mailbox_idnr of "
                      "INBOX for user [%llu], exiting..",
                      __FILE__, __func__, user_idnr);
                return -1;
        }
        if (db_findmailbox("Spam", user_idnr, &spam_mailbox_idnr) <= 0) {
                spam_mailbox_idnr = inbox_mailbox_idnr;
        }
        /* query is <2 because we don't want deleted messages
         * the unique_id should not be empty, this could mean that the message 
is still being delivered */
        snprintf(query, DEF_QUERYSIZE,
                 "SELECT pm.messagesize, msg.message_idnr, msg.status, "
                 "msg.unique_id FROM dbmail_messages msg, dbmail_physmessage pm 
"
                 "WHERE ( msg.mailbox_idnr = '%llu' OR msg.mailbox_idnr = 
'%llu' )"
                 "AND msg.status < '%d' "
                 "AND msg.physmessage_id = pm.id "
                 "order by status ASC",
                 inbox_mailbox_idnr, spam_mailbox_idnr, MESSAGE_STATUS_DELETE);





--
With best regards, Danil.

Reply via email to