[FW][MERGE] base, mail, fetchmail: make 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 and outgoing mail servers. Some hints are given in the error message. A link to the documentation is also added in mail: Settings > External Email Servers feature: add a link to this doc: https://www.odoo.com/documentation/user/13.0/discuss/advanced/email_servers.html Task ID-22736 PR #54176 closes odoo/odoo#56556 Forward-port-of: odoo/odoo#54176 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="external_email_server_default"/>
|
||||
<a href="https://www.odoo.com/documentation/user/13.0/discuss/advanced/email_servers.html" title="Documentation" class="o_doc_link" target="_blank"></a>
|
||||
<div class="text-muted" id="external_email_server_default">
|
||||
Configure your own email servers
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,8 @@ import email.policy
|
||||
import logging
|
||||
import re
|
||||
import smtplib
|
||||
from socket import gaierror, timeout
|
||||
from ssl import SSLError
|
||||
import sys
|
||||
import threading
|
||||
|
||||
@@ -129,6 +131,18 @@ class IrMailServer(models.Model):
|
||||
except UserError as e:
|
||||
# let UserErrors (messages) bubble up
|
||||
raise e
|
||||
except UnicodeError as e:
|
||||
raise UserError(_("Invalid server name !\n %s", ustr(e)))
|
||||
except (gaierror, timeout) as e:
|
||||
raise UserError(_("No response received. Check server address and port number.\n %s", ustr(e)))
|
||||
except smtplib.SMTPServerDisconnected as e:
|
||||
raise UserError(_("The server has closed the connection unexpectedly. Check configuration served on this port number.\n %s", ustr(e.strerror)))
|
||||
except smtplib.SMTPResponseException as e:
|
||||
raise UserError(_("Server replied with following exception:\n %s", ustr(e.smtp_error)))
|
||||
except smtplib.SMTPException as e:
|
||||
raise UserError(_("An SMTP exception occurred. Check port number and connection security type.\n %s", ustr(e.smtp_error)))
|
||||
except SSLError as e:
|
||||
raise UserError(_("An SSL exception occurred. Check connection security type.\n %s", ustr(e)))
|
||||
except Exception as e:
|
||||
raise UserError(_("Connection Test Failed! Here is what we got instead:\n %s", ustr(e)))
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user