OCA / server-tools

Tools for Odoo Administrators to improve some technical features on Odoo.
https://odoo-community.org/psc-teams/tools-30
GNU Affero General Public License v3.0
706 stars 1.5k forks source link

Errors produced by fetchmail_attach_from_folder #247

Closed limor1 closed 8 years ago

limor1 commented 9 years ago

I'm getting this log error every time fetchmail is run in crontab or manually

2015-09-02 06:09:04,798 9318 INFO robosavvy openerp.addons.fetchmail_attach_from_folder.model.fetchmail_server: start checking for emails in CRM-Leads server Nuno
2015-09-02 06:09:05,024 9318 INFO robosavvy openerp.addons.fetchmail_attach_from_folder.model.fetchmail_server: finished checking for emails in CRM-Leads server Nuno
2015-09-02 06:09:05,024 9318 INFO robosavvy openerp.addons.fetchmail_attach_from_folder.model.fetchmail_server: start checking for emails in CRM-Customers server Nuno
2015-09-02 06:09:05,272 9318 INFO robosavvy openerp.addons.fetchmail_attach_from_folder.model.fetchmail_server: finished checking for emails in CRM-Customers server Nuno
2015-09-02 06:09:05,708 9318 ERROR robosavvy openerp.addons.base.ir.ir_cron: Call of self.pool.get('fetchmail.server')._fetch_mails(cr, uid, *()) failed in Job 6
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_cron.py", line 138, in _callback
    getattr(model, method_name)(cr, uid, *args)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/fetchmail/fetchmail.py", line 187, in _fetch_mails
    return self.fetch_mail(cr, uid, ids, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/var/lib/odoo/.local/share/Odoo/addons/8.0/fetchmail_attach_from_folder/model/fetchmail_server.py", line 73, in fetch_mail
    connection.close()
  File "/usr/lib/python2.7/imaplib.py", line 394, in close
    typ, dat = self._simple_command('CLOSE')
  File "/usr/lib/python2.7/imaplib.py", line 1087, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python2.7/imaplib.py", line 837, in _command
    ', '.join(Commands[name])))
error: command CLOSE illegal in state AUTH, only allowed in states SELECTED

There are two folder rules for IMAP account "Nuno":

This rule creates leads from emails showing up in folder CRM-Leads - it works as expected (although unfortunately it only catches incoming emails, not outgoing emails) crm-leads

This rule is supposed to create message threads associated with customers - this doesnt seem to do anything. no mails are read :( crm-customers

hbrunn commented 9 years ago

@limor1 say connection.debug = 4 after https://github.com/OCA/server-tools/blob/8.0/fetchmail_attach_from_folder/model/fetchmail_server.py#L70 and post the output. This logs to stderr, so you'll have to run your server in the foreground

intero-chz commented 9 years ago

Hi, i got the same problem with following configuration:

  1. some incoming email accounts without using folder feature
  2. one incoming email account with two folder lines on INBOX

The second part works well. The first part not, because of this error above.

My very fast but ugly solution in fetchmail_server(skip connection if no folders):

#FROM
connection = this.connect()
for folder in this.folder_ids.filtered('active'):
    this.handle_folder(connection, folder)
connection.close()

#TO
if this.folder_ids.filtered('active'):
    connection = this.connect()
    for folder in this.folder_ids.filtered('active'):
        this.handle_folder(connection, folder)
    connection.close()