Skip to content

Commit

Permalink
Fix #7223: Support sending to smtp server without authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
e-carlin committed Aug 23, 2024
1 parent 5cf751c commit 35c7bb7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sirepo/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def _send_directly(msg):
s.send_message(msg)


def _send_with_auth(msg):
def _send_to_configured_smtp_server(msg):
with smtplib.SMTP(_cfg.server, _cfg.port) as s:
s.starttls()
s.ehlo()
s.login(_cfg.user, _cfg.password)
if _cfg.user and _cfg.password:
s.login(_cfg.user, _cfg.password)
s.send_message(msg)


Expand All @@ -94,14 +95,14 @@ def _init():
_cfg.server = "not " + _DEV_SMTP_SERVER
_SEND = _send_directly
return
_SEND = _send_with_auth
_SEND = _send_to_configured_smtp_server
if pkconfig.in_dev_mode():
if _cfg.server is None:
_cfg.server = _DEV_SMTP_SERVER
return
if _cfg.server is None or _cfg.user is None or _cfg.password is None:
if _cfg.server is None:
pkconfig.raise_error(
f"server={_cfg.server}, user={_cfg.user}, and password={_cfg.password} must be defined",
f"server={_cfg.server} must be defined",
)


Expand Down

0 comments on commit 35c7bb7

Please sign in to comment.