I was attempting to set up email report delivery via SMTP for the first time and experienced the following error:
Traceback (most recent call last):
File "/home/user/.local/bin/urlwatch", line 375, in <module>
main(parser.parse_args())
File "/home/user/.local/bin/urlwatch", line 342, in main
report.finish()
File "/home/user/.local/lib/python3.4/site-packages/urlwatch/handler.py", line 128, in finish
ReporterBase.submit_all(self, self.job_states, duration)
File "/home/user/.local/lib/python3.4/site-packages/urlwatch/reporters.py", line 81, in submit_all
cls(report, cfg, job_states, duration).submit()
File "/home/user/.local/lib/python3.4/site-packages/urlwatch/reporters.py", line 340, in submit
mailer.send(msg)
File "/home/user/.local/lib/python3.4/site-packages/urlwatch/mailer.py", line 57, in send
s.starttls()
File "/usr/lib/python3.4/smtplib.py", line 688, in starttls
server_hostname=self._host)
File "/usr/lib/python3.4/ssl.py", line 365, in wrap_socket
_context=self)
File "/usr/lib/python3.4/ssl.py", line 583, in __init__
self.do_handshake()
File "/usr/lib/python3.4/ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_UNRECOGNIZED_NAME] tlsv1 unrecognized name (_ssl.c:600)
I was using smtp.gmail.com:587 but observed the same behavior with other mail servers as well.
import smtplib
s = smtplib.SMTP()
s.connect('smtp.gmail.com', 587)
s.ehlo()
s.starttls()
import smtplib
s = smtplib.SMTP()
s.connect('smtp.gmail.com', 587)
s._host = 'smtp.gmail.com'
s.ehlo()
s.starttls()
52,53c52
< s = smtplib.SMTP()
< s.connect(self.smtp_server, self.smtp_port)
---
> s = smtplib.SMTP(self.smtp_server, self.smtp_port)