Skip to Content
Menu
This question has been flagged
2 Replies
1022 Views

Dear,


After connecting my company email to oddo 15 using IMAP, I started facing the following issue:


- All the emails that are downloaded to outlook are marked read even if I didn't read them yet on any device or webmail.


Our hosting is on Google , I contacted google support and they informed me that a 3rd party is reading the email.


After removing the permission from google (app passwords), the problem was solved.


Any idea what could be the problem or anyone had the same issue before?

Taking into consideration that other users are using POP3 and they don't have this issue.

Avatar
Discard
Best Answer

Hello Charbell Hajj,

• Your Issue comes from the “method fetch_mail” which is in “fetchmail.py” inside fetchmail module.

Please find Code in comment. 

As we can see here in the reference “server type is IMAP”, therefore the mails are fetched by flag which are “UNSEEN” and odoo sets mail flag to “SEEN” at the end of the process, so that they didn’t get fetch again.

So you can modify the search condition, according to which the mails will be fetched from the last fetched date.

last_fetch_date = server.date.strftime('%d-%b-%Y')
imap_server.search(None, '(ALL SINCE last_fetch_date)') 


and need to remove “imap_server.store(num, '+FLAGS', '\\Seen')“ and “imap_server.store(num, '-FLAGS', '\\Seen')” as it modifies flag.

• Here “date” in “server.date” is a “Last Fetch Date” field of fetchmail module and note that the timezone is UTC here.

• For more search options you can refer,
https://gist.github.com/martinrusev/6121028 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwar

Avatar
Discard

For your reference:

if server.server_type == 'imap':
try:
.....
result, data = imap_server.search(None, '(UNSEEN)')
for num in data[0].split():
res_id = None
result, data = imap_server.fetch(num, '(RFC822)')
imap_server.store(num, '-FLAGS', '\\Seen')
try:
res_id = MailThread.with_context(**additionnal_context).message_process(server.object_id.model, data[0][1], save_original=server.original, strip_attachments=(not server.attach))
except Exception:
......
imap_server.store(num, '+FLAGS', '\\Seen') <--- Here is your problem..
and so on ...

Author Best Answer

Dear Jainesh,

Thank you for you reply.

Will check this.


Avatar
Discard