last_mail_id are not updated when updating IMAP/POP server informations

Bug #494664 reported by Sylvain Calador
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Power Email
Triaged
Undecided
Unassigned

Bug Description

I can download mail successfully with POP but have no success with IMAP, using gmail.

Any ideas?
-----------------------------------------------------------------------------------------------------------------------------------------------
Hi,

I have found that "last_mail_id" in poweremail_core_account is not updated when
updating powermail account.
If the previous account had last_mail_id superior at the new one, no mail are download from the server.

I will try to patch this but it is difficult because side effects like "duplicated mails" if the patch set the last_email_id
is to 0 when the account state is set to approve like this:

=== modified file 'poweremail_core.py'
--- poweremail_core.py 2009-12-08 13:33:45 +0000
+++ poweremail_core.py 2009-12-09 18:57:19 +0000
@@ -180,7 +180,7 @@

     def do_approval(self, cr, uid, ids, context={}):
         #TODO: Check if user has rights
- self.write(cr, uid, ids, {'state':'approved'}, context=context)
+ self.write(cr, uid, ids, {'state':'approved', 'last_mail_id':0}, context=context)
 # wf_service = netsvc.LocalService("workflow")

     def get_reapprove(self, cr, uid, ids, context={}):

To bypass this issue, create a new account (if you modify account/server informations) and remove the previous one.

Best regards,

Sylvain

Changed in poweremail:
status: New → Triaged
Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

How about having an extra button to reset email counter.
Warning: Will download all mails again? How does that sound?

Revision history for this message
Sylvain Calador (sylvain-calador) wrote :

Hi Sharoon,

Maybe I'm wrong but I think a good solution is to clean the inbox and reset the email counter to 0
if a the incoming server information is updated.

1. The good thing is that we are sure that poweremeail can get all email and isn't bloqued by email counter.
2. The bad thing is: if the user has move some incoming mails to other folder, he has duplicated mails in inbox.

I think it is possible to find a solution to 2. by parsing email header.

Find a patch attached,

Don't hesitate to tell me if there is something wrong or if you thing somthing is a bad idea
for poweremail.

Best regards,
Sylvain

Revision history for this message
Sylvain Calador (sylvain-calador) wrote :

Hi,

This is my final proposition for solving this bug.
I think that using the Message-ID of email header is a better idea.
So I have added a field "pem_message_id" to poweremail.mailbox object that is the
md5 digest of the email Message-ID (because the original Message-ID can be of
arbitrary length, and because printing orignal Message-ID in log is a bad idea...)
Then I have added a unicity sql constraint "unique(pem_message_id,pem_to,pem_account_id)"
to prevent duplicated emails, and I set autocommit to "True" when downloading header (or full email),
so when we try to create an email in mailbox, we check if the header (or full email) have been
already downloaded.
When we have not a Message-ID (for exemple when we save a new email in poweremail) or when the email
has not been delivered (like Thunderbird Sent folder emails which have the same id that delivered ones)
we create a unique random Message-ID based on timestamp and random string.

In other word that solved the problem of duplicated emails.
(Message-ID have been created mainly for that, in addition saving "Message-ID" in mailbox can be used for conversation)

In conclusion, the email counter of mailbox is reset to "0"
when important fields of incoming server are updated (excluded port and account password),
and as there is a check on duplicated email, the user can keep all the emails of his previous account
(no need to delete any email like my previous patch)

This patch also fixed 2 bugs when downloading full email with attachements.

Hope this patch could be included in trunk, in this case I can propose a merge.

Best regards,

Sylvain

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.