credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #06150
[Branch ~credativ/openobject-addons/6.1] Rev 7077: [FIX] Skip invalid mail messages and try again next time
------------------------------------------------------------
revno: 7077
committer: Craig Gowing (credativ) <craig.gowing@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Tue 2016-05-24 10:42:29 +0100
message:
[FIX] Skip invalid mail messages and try again next time
modified:
fetchmail/fetchmail.py
--
lp:~credativ/openobject-addons/6.1
https://code.launchpad.net/~credativ/openobject-addons/6.1
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/6.1.
To unsubscribe from this branch go to https://code.launchpad.net/~credativ/openobject-addons/6.1/+edit-subscription
=== modified file 'fetchmail/fetchmail.py'
--- fetchmail/fetchmail.py 2012-07-27 13:50:07 +0000
+++ fetchmail/fetchmail.py 2016-05-24 09:42:29 +0000
@@ -180,6 +180,7 @@
logger.info('start checking for new emails on %s server %s', server.type, server.name)
context.update({'fetchmail_server_id': server.id, 'server_type': server.type})
count = 0
+ failed = 0
imap_server = False
pop_server = False
if server.type == 'imap':
@@ -188,18 +189,22 @@
imap_server.select()
result, data = imap_server.search(None, '(UNSEEN)')
for num in data[0].split():
- result, data = imap_server.fetch(num, '(RFC822)')
- imap_server.store(num, '-FLAGS', '\\Seen')
- res_id = mail_thread.message_process(cr, uid, server.object_id.model, data[0][1],
- save_original=server.original,
- strip_attachments=(not server.attach),
- context=context)
- if res_id and server.action_id:
- action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids': [res_id], 'active_model': server.object_id.model})
- imap_server.store(num, '+FLAGS', '\\Seen')
- cr.commit()
- count += 1
- logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name)
+ try:
+ result, data = imap_server.fetch(num, '(RFC822)')
+ imap_server.store(num, '-FLAGS', '\\Seen')
+ res_id = mail_thread.message_process(cr, uid, server.object_id.model, data[0][1],
+ save_original=server.original,
+ strip_attachments=(not server.attach),
+ context=context)
+ if res_id and server.action_id:
+ action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids': [res_id], 'active_model': server.object_id.model})
+ imap_server.store(num, '+FLAGS', '\\Seen')
+ cr.commit()
+ count += 1
+ except Exception, e:
+ failed += 1
+ logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
+ logger.info("fetched/processed %s email(s) on %s server %s - %s failed", count, server.type, server.name, failed)
except Exception, e:
logger.exception("Failed to fetch mail from %s server %s", server.type, server.name)
finally: