Files
odoo_source/addons/mail/tools/mail_validation.py
T
jorv 54dcdda950 [FIX] mail: Make flanker log message more general
The `flanker` python library can be installed to implement optional
email address validation.
Nevertheless, it is not fully supported in python 3 (see https://github.com/mailgun/flanker).

Recent issues point to the fact that the latest pip release version 0.9.11
does not work under python 3.10.
This can lead to features, using the email validation, creating blocking
behavior due to error tracebacks.

As this is more of an issue on flanker's side than Odoo's, we remove the
`pip install` instruction. It can be assumed that someone wanting to go
out of their way to install flanker, should be proficient enough to either
make sure the python <3.10 is running or install one of the Github repo tagged
versions.

After this change, we still inform the user of the optional feature, but do not directly
incite them to pip install it, which should prevent normal users from
inadvertently blocking parts of their Odoo database.

opw-3562596

closes odoo/odoo#139800

X-original-commit: 637e60cb9687e9859d081f7367717c84d29fb82a
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-10-26 06:16:16 +00:00

28 lines
862 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import tools
_logger = logging.getLogger(__name__)
_flanker_lib_warning = False
try:
from flanker.addresslib import address
# Avoid warning each time a mx server is not reachable by flanker
logging.getLogger("flanker.addresslib.validate").setLevel(logging.ERROR)
def mail_validate(email):
return bool(address.validate_address(email))
except ImportError:
def mail_validate(email):
global _flanker_lib_warning
if not _flanker_lib_warning:
_flanker_lib_warning = True
_logger.info("The (optional) `flanker` Python module is not installed,"
"so email validation will fallback to email_normalize.")
return tools.email_normalize(email)