martomi / chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.
MIT License
457 stars 120 forks source link

Email notification shouldn't require username and password #98

Open kungfoome opened 3 years ago

kungfoome commented 3 years ago

Describe the bug

https://github.com/martomi/chiadog/blob/da1a904466e6df25b930d58cefb70eca6dce4a3a/src/notifier/smtp_notifier.py#L18-L29

Currently username and password have to be specified. I use gmail SMTP relay service for all notifications as such, which doesn't require a username and password.

Proposal Remove and assign non-required arguments out of the try block:

Add a conditional here instead: https://github.com/martomi/chiadog/blob/da1a904466e6df25b930d58cefb70eca6dce4a3a/src/notifier/smtp_notifier.py#L60

something like this could suffice for now:

if self.username_smtp and self.password_smtp:
  server.login(self.username_smtp, self.password_smtp)

Other Thoughts This could probably be built out a bit better over time to support other options. If the connection pieces were moved into its own function from a message builder function, that could help a bit.

Something else that probably won't work is using no encryption or ssl since that is also forced.