tools (common/email): use from_email is specified, always set email_sender_domain
This commit is contained in:
parent
d0973d121d
commit
8946b6fb4e
1 changed files with 13 additions and 11 deletions
|
|
@ -43,19 +43,21 @@ def sendEmail(config, to_emails, subject="", body="", from_email=None):
|
||||||
if isinstance(to_emails, str):
|
if isinstance(to_emails, str):
|
||||||
to_emails = to_emails.split()
|
to_emails = to_emails.split()
|
||||||
email_host = tools_config.getConfig(config, None, "email_server") or "localhost"
|
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:
|
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_from = "no_reply@" + domain
|
||||||
email_sender_domain = tools_config.getConfig(config, None, "email_sender_domain")
|
email_sender_domain = tools_config.getConfig(
|
||||||
if email_sender_domain is None and smtp.DNSNAME == b"localhost.localdomain":
|
config, None, "email_sender_domain", domain
|
||||||
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_port = int(tools_config.getConfig(config, None, "email_port", 25))
|
email_port = int(tools_config.getConfig(config, None, "email_port", 25))
|
||||||
email_username = tools_config.getConfig(config, None, "email_username")
|
email_username = tools_config.getConfig(config, None, "email_username")
|
||||||
email_password = tools_config.getConfig(config, None, "email_password")
|
email_password = tools_config.getConfig(config, None, "email_password")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue