Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option to disable SMTP auth for basic postfix setup #314

Merged
merged 2 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ notifier:
recipient: 'you@example.com'
username_smtp: 'username'
password_smtp: 'password'
enable_smtp_auth: true
host: 'smtp.example.com'
port: 587
script:
Expand Down
4 changes: 3 additions & 1 deletion src/notifier/smtp_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, title_prefix: str, config: dict):
self.password_smtp = credentials["password_smtp"]
self.host = credentials["host"]
self.port = credentials["port"]
self.enable_smtp_auth = credentials.get("enable_smtp_auth", True)

except KeyError as key:
logging.error(f"Invalid config.yaml. Missing key: {key}")
Expand Down Expand Up @@ -57,7 +58,8 @@ def send_events_to_user(self, events: List[Event]) -> bool:
server.starttls()
# stmplib docs recommend calling ehlo() before & after starttls()
server.ehlo()
server.login(self.username_smtp, self.password_smtp)
if self.enable_smtp_auth:
server.login(self.username_smtp, self.password_smtp)
server.sendmail(self.sender, self.recipient, msg.as_string())
server.quit()
# Display an error message if something goes wrong.
Expand Down