Skip to content

Commit

Permalink
Use property access since attributes are defined as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Aug 6, 2024
1 parent 6d7a8ef commit 5fdc7c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def send(ctx, to, actor, subject, body, cc=None):
('reply_to', 'notifications_reply_to'),
('server', 'smtp_server')]}

if getattr(config, "smtp_auth"):
cfg['username'] = getattr(config, "smtp_username")
cfg['password'] = getattr(config, "smtp_password")
if config.smtp_auth:
cfg['username'] = config.smtp_username
cfg['password'] = config.smtp_password

try:
# e.g. 'smtps://smtp.gmail.com:465' for SMTP over TLS, or
Expand All @@ -65,7 +65,7 @@ def send(ctx, to, actor, subject, body, cc=None):
try:
smtp = (smtplib.SMTP_SSL if proto == 'smtps' else smtplib.SMTP)(host, port)

if proto != 'smtps' and getattr(config, "smtp_starttls"):
if proto != 'smtps' and config.smtp_starttls:
# Enforce TLS.
smtp.starttls()

Expand All @@ -74,7 +74,7 @@ def send(ctx, to, actor, subject, body, cc=None):
return api.Error('internal', 'Mail configuration error')

try:
if getattr(config, "smtp_auth"):
if config.smtp_auth:
smtp.login(cfg['username'], cfg['password'])

except Exception:
Expand Down

0 comments on commit 5fdc7c4

Please sign in to comment.