[IMP] base, mail: make outgoing 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 outgoing mail server connection and giving related hints. 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-2273671 PR #54176 X-original-commit: d30682f4d4aeaefa077ba284a60c93f3a020365f
This commit is contained in:
committed by
Thibault Delavallée
parent
3eec4d6a69
commit
606bf9b51c
@@ -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