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

Feature request: Support for SMTP server without validation #36

Open
bipsendk opened this issue Jun 5, 2017 · 1 comment
Open

Feature request: Support for SMTP server without validation #36

bipsendk opened this issue Jun 5, 2017 · 1 comment

Comments

@bipsendk
Copy link

bipsendk commented Jun 5, 2017

It would be nice, if the plugin supported to use a standard SMTP server (that allows relaying) without having to enter user credentials.

@automatedelectrics
Copy link

automatedelectrics commented Nov 27, 2018

It maybe a bit late to help with this particular problem, but it might help someone else in the future ...

I was stuck with the same issue recently where I tried to set up Email Notifier without authentication because we run our own email server locally and sending an email from a client will fail if we try to use any type of authentication.

In the end the solution which worked for us was;

  1. SSH into OctoPi and open the file __init__.py which was located under
    /home/pi/oprint/lib/python2.7/site-packages/octoprint_emailnotifier
  2. At the end of the file, comment out the line;
    mailer = yagmail.SMTP(user={self._settings.get(['mail_username']):self._settings.get(['mail_useralias'])}, host=self._settings.get(['mail_server']),port=self._settings.get(['mail_server_port']), smtp_starttls=self._settings.get(['mail_server_tls']), smtp_ssl=self._settings.get(['mail_server_ssl']))
  3. Add a new line directly under with the following;
    mailer = yagmail.SMTP(user=self._settings.get(['mail_username']), password=None, host=self._settings.get(['mail_server']), port=self._settings.get(['mail_server_port']), smtp_skip_login=True, smtp_starttls=self._settings.get(['mail_server_tls']), smtp_ssl=self._settings.get(['mail_server_ssl']))
  4. Save and reboot the Pi.

The key changes to the original line were;
Removed self._settings.get(['mail_useralias']) (we didn't need the alias parameter)
Added password=None (you still need a username for the "From" section of the email, but no P/W)
Added smtp_skip_login=True (this was the big one!)

You can directly edit the existing line if you like, but I always like to keep the original code as a reference (particularly when testing) or just in case something goes wrong and you need to revert back.

Additionally, we also needed to add our desired username to a new file in the home directory which caused another error (because the yagmail was looking for this file, which was missing). The username is just used for the "From" section of the email sent, and in our case it didn't even need to be a valid user on our email system (update the "{ }" sections in the following to suit).
echo {Username}@{Email Address} > ~/.yagmail

I hope this helps!

OctoPrint Email Notifier Settings Example for No SMTP Authentication
email notifier example settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants