[FIX] base: select appropriate address for SMTP connection check
Before this patch, when doing an SMTP connectivity check, Odoo always checked if the current user with their current email address could connect. That was inaccurate because: 1. If the `ir.mail_server` were configured with an email address as `from_filter`, that's going to be the address used to connect with the server always; never your user email. 2. If it were configured with a domain as `from_filter` and your user had an email from another domain, your outgoing emails are going to get wrapped into that domain (SRS-like). Again, the connectivity check wouldn't be imitating real world connections. After the patch, both situations are taken into account when deciding the outgoing address that's going to be used for testing the connection. This will reduce false negatives when testing connectivity. @moduon MT-1064 OPW-2942814 closes odoo/odoo#105033 X-original-commit: f1e5e8ca42fbab77649b95fd0b2d09c46f6878fc Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
This commit is contained in:
@@ -195,6 +195,14 @@ class IrMailServer(models.Model):
|
||||
|
||||
def _get_test_email_addresses(self):
|
||||
self.ensure_one()
|
||||
if self.from_filter:
|
||||
if "@" in self.from_filter:
|
||||
# All emails will be sent from the same address
|
||||
return self.from_filter, "noreply@odoo.com"
|
||||
# All emails will be sent from any address in the same domain
|
||||
default_from = self.env["ir.config_parameter"].sudo().get_param("mail.default.from", "odoo")
|
||||
return f"{default_from}@{self.from_filter}", "noreply@odoo.com"
|
||||
# Fallback to current user email if there's no from filter
|
||||
email_from = self.env.user.email
|
||||
if not email_from:
|
||||
raise UserError(_('Please configure an email on the current user to simulate '
|
||||
|
||||
Reference in New Issue
Block a user