diff options
| author | Bruno Boi <boi@odoo.com> | 2020-07-08 07:44:25 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-26 07:05:04 +0000 |
| commit | f0ebeb96a05abc76d2acb77707a79f40e6999375 (patch) | |
| tree | 3ba17a829f6a4f02bdbee279245ba82c3303b1c6 /addons/fetchmail/models | |
| parent | d30682f4d4aeaefa077ba284a60c93f3a020365f (diff) | |
[IMP] fetchmail: make incoming mail server configuration more user friendly
PURPOSE
Ease the configuration of external email servers by adding links to the
documentation and by making errors more user friendly.
SPECIFICATIONS
This is done by catching more exceptions when testing incoming mail server
connection and giving related hints.
Task ID-2273671
PR #54176
Diffstat (limited to 'addons/fetchmail/models')
| -rw-r--r-- | addons/fetchmail/models/fetchmail.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/fetchmail/models/fetchmail.py b/addons/fetchmail/models/fetchmail.py index da83677a02c..0850f5e19ee 100644 --- a/addons/fetchmail/models/fetchmail.py +++ b/addons/fetchmail/models/fetchmail.py @@ -3,6 +3,8 @@ import logging import poplib +from ssl import SSLError +from socket import gaierror, timeout from imaplib import IMAP4, IMAP4_SSL from poplib import POP3, POP3_SSL @@ -124,7 +126,15 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO try: connection = server.connect() server.write({'state': 'done'}) - except Exception as err: + except UnicodeError as e: + raise UserError(_("Invalid server name !\n %s", tools.ustr(e))) + except (gaierror, timeout, IMAP4.abort) as e: + raise UserError(_("No response received. Check server information.\n %s", tools.ustr(e))) + except (IMAP4.error, poplib.error_proto) as err: + raise UserError(_("Server replied with following exception:\n %s", tools.ustr(err))) + except SSLError as e: + raise UserError(_("An SSL exception occurred. Check SSL/TLS configuration on server port.\n %s", tools.ustr(e))) + except (OSError, Exception) as err: _logger.info("Failed to connect to %s server %s.", server.server_type, server.name, exc_info=True) raise UserError(_("Connection test failed: %s", tools.ustr(err))) finally: |
