Email / keyring error
Hi - I am trying to setup email notifications through a connection to smtp.gmail.com with port 465 and 587. My config file looks like this:
report:
email:
enabled: true
from: '[email protected]'
html: true
method: smtp
sendmail:
path: sendmail
smtp:
host: 'smtp.gmail.com'
keyring: true
port: 465
starttls: true
subject: '{count} changes: {jobs}'
My MacOSXKeychain has the smtp.gmail.com password stored. Not sure what I need to do to fix this. Thanks!
` File "/Library/Frameworks/Python.framework/Versions/3.6/bin/urlwatch", line 101, in <module>
urlwatch_command.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/command.py", line 167, in run
self.urlwatcher.close()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/main.py", line 96, in close
self.report.finish()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/handler.py", line 125, in finish
ReporterBase.submit_all(self, self.job_states, duration)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/reporters.py", line 92, in submit_all
subclass(report, cfg, job_states, duration).submit()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/reporters.py", line 362, in submit
mailer.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urlwatch/mailer.py", line 82, in send
s = smtplib.SMTP(self.smtp_server, self.smtp_port)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py", line 306, in _get_socket
self.source_address)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 722, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused`
Did you try a different port? From a "gmail smtp" Google search, I find for example https://www.lifewire.com/what-are-the-gmail-smtp-settings-1170854, which suggests port 587.
Yes, I have also tried switching ports. Any other ideas?
Have you tried with a different mail server?
/root/.config/urlwatch/urlwatch.yaml
report:
email:
enabled: true
from: 'My Email <[email protected]>'
html: false
method: smtp
sendmail:
path: sendmail
smtp:
host: smtp.gmail.com
keyring: true
port: 587
starttls: true
user: [email protected]
subject: '{count} changes: {jobs}'
to: '[email protected]'
With the above configuration, there are still errors:
File "/usr/lib/python3.5/smtplib.py", line 641, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt-\n5.7.14 3-SWf1cJpfAzECbag4kmQmBWi66Xja1YBppSMOYABtkF6EPD0uFoZBL9DZdTPKkLvatJHg\n5.7.14 ipqCt2KR5OLmtSys_dzRVNNA52ZMWnQ_7gBg3awWHcKtlhNbq6S-6Lnd3L3d_uo-vE_iGq\n5.7.14 1pOe-kYII86GoC1sx3rS7L8RiMtJWqEKCAfIAqSv5Pf1LJV3UhKp-qxSm4LpgcQqPocIc3\n5.7.14 QnsnzYTk9rTnAv3hM1LoDH1pIAtQc> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 x26sm779318wmc.12 - gsmtp')
In order to fix this, 2 extra steps are needed:
-
https://support.google.com/accounts/answer/6010255 Let less secure apps use your account, turn On at https://myaccount.google.com/lesssecureapps
-
http://joequery.me/guides/python-smtp-authenticationerror/ Step 3: Disabling CAPTCHA for clients at http://www.google.com/accounts/DisplayUnlockCaptcha
I also struggled with configuring email notifications and I think this question highlights the need for additional documentation of that feature more generally (especially given the other similar issue opened on the same topic: https://github.com/thp/urlwatch/issues/197 ).
I was able to get email notifications working using @eurodomenii 's example/instructions so I think including them in the readme (or as separate instructions linked to in the readme) would be a great addition.