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

Notifications via e-mail not working? #24

Open
blu-IT opened this issue Aug 6, 2016 · 6 comments
Open

Notifications via e-mail not working? #24

blu-IT opened this issue Aug 6, 2016 · 6 comments

Comments

@blu-IT
Copy link

blu-IT commented Aug 6, 2016

Hello,

I tried different configurations for sending automated notification after backup.

When configuring

MAIL_SMTP_SERVER = 'smtp.myserver.de'

then I get

smtplib.SMTPSenderRefused: (550, '5.7.1 Authentication Required','')

and when I configure

MAIL_SMTP_SERVER = 'localhost'

(with working ssmtp.config) there is an error like "Network is unreachable".

So where do I set config parms for authentication with external smtp-hosts or how to get in touch with my local ssmtp-host in a working manner?

Thanks!

@blu-IT
Copy link
Author

blu-IT commented Aug 7, 2016

OK, after doing some additional research I found a solution for using aexternal smtp-host with ssl/starttls:

MAIL_SMTP_SERVER = 'smtp.myserver.de'

I added these two lines at the code after line 521/522

s.starttls() # needed if SSL/StartTLS is required (Port 465)
s.login('myuser', 'mypassword') # insert your e-mailuseraccount/password here

So code from line 519 looks like this now:

# note if using an ipaddress in MAIL_SMTP_SERVER, 
# then may require smtplib.SMTP(MAIL_SMTP_SERVER, local_hostname="localhost")
s = smtplib.SMTP(MAIL_SMTP_SERVER)
s.starttls()  # needed if SSL/StartTLS is required (Port 465)
s.login('myuser', 'mypassword') # insert your e-mailuseraccount/password here
s.sendmail(MAIL_FROM_ADDR, to.split(','), msg.as_string())
s.quit()

@blu-IT blu-IT closed this as completed Aug 7, 2016
@blu-IT blu-IT reopened this Aug 10, 2016
@blu-IT
Copy link
Author

blu-IT commented Aug 10, 2016

Added my modifications to the code. I would like to pull..

@NAUbackup
Copy link
Owner

That's indeed needed if you are requires to authenticate to connect to an SMTP with that requirement. Have you tried using the password encryption mechanism built in to try to obfuscate the password information?

@blu-IT
Copy link
Author

blu-IT commented Sep 7, 2016

Hi,
I'm not quite shure which password encryption mechanism you mean.
The one for starting the script without an user action (yes - it works) or for encryption of the mailuseraccount (no - is there any mechanism/way)?
As my problem is/was related to mail sending (SSL/StartTLS), I could fix that with the code I posted before. Still would like to see it in the future code ;-)

Regards

@NAUbackup
Copy link
Owner

NAUbackup commented Oct 30, 2016

For now, to clarify, we do not have the means to handle SMTP password authentication. We can put it on the long-term desired features list. Looksclike you'd need to use an s.login mechanism, such as discussed here: http://stackoverflow.com/questions/14196581/python-smtp-requires-authentication

@NAUbackup
Copy link
Owner

NAUbackup commented Nov 26, 2016

The more conventional code would look something like this. Port 587 is preferred for SMTP/TLS authentication:

server = smtplib.SMTP(MAIL_SMTP_SERVER:587)
or
server = smtplib.SMTP(MAIL_SMTP_SERVER,587)
server.ehlo()
server.starttls()
server.login(username, password)

and so on.

In any case, it's on the list of things to strongly consider building in since it's not hard to do, but ould take some work to incorporate the logic to support both it and the conventional means with minimal code disruption. Different mail gateways also require different username conventions, some, for example, require the domain be included, some the email address, others just th esimple username, etc. so there is more to go wrong when setting things up.

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

No branches or pull requests

2 participants