# HG changeset patch # User Goffi # Date 1652699033 -7200 # Node ID 2c187445a3d33ee79c068f28fa3dc490a8c257ea # Parent 89b13b405b9347696ba5a9ada1187346928f34ad tools (common/email): use `from_email` is specified, always set `email_sender_domain` diff -r 89b13b405b93 -r 2c187445a3d3 sat/tools/common/email.py --- a/sat/tools/common/email.py Mon May 16 13:02:59 2022 +0200 +++ b/sat/tools/common/email.py Mon May 16 13:03:53 2022 +0200 @@ -43,19 +43,21 @@ if isinstance(to_emails, str): to_emails = to_emails.split() email_host = tools_config.getConfig(config, None, "email_server") or "localhost" - email_from = tools_config.getConfig(config, None, "email_from") + email_from = from_email or tools_config.getConfig(config, None, "email_from") + + # we suppose that email domain and XMPP domain are identical + domain = tools_config.getConfig(config, None, "xmpp_domain") + if domain is None: + if email_from is not None: + domain = email_from.split("@", 1)[-1] + else: + domain = "example.net" + if email_from is None: - # we suppose that email domain and XMPP domain are identical - domain = tools_config.getConfig(config, None, "xmpp_domain", "example.net") email_from = "no_reply@" + domain - email_sender_domain = tools_config.getConfig(config, None, "email_sender_domain") - if email_sender_domain is None and smtp.DNSNAME == b"localhost.localdomain": - try: - email_sender_domain = email_from.split('@')[1] - except IndexError: - log.warning( - "Can't set email_sender_domain domain du to invalid email_from: " - f"{email_from!r}") + email_sender_domain = tools_config.getConfig( + config, None, "email_sender_domain", domain + ) email_port = int(tools_config.getConfig(config, None, "email_port", 25)) email_username = tools_config.getConfig(config, None, "email_username") email_password = tools_config.getConfig(config, None, "email_password")