Fix for smtp-servers using SSL

Fix for smtp-servers using SSL, works with gmail.com, yandex.ru and other public servers with ssl. Variant with smtplib.SMTP doesn't work with smtp.yandex.ru (popular public mail provider in Russia, something like google, but local) returning "SMTPServerDisconnected: Connection unexpectedly closed" error, same with gmail. Seems like SSL is everywhere nowdays, so should work most modern smtp servers.
This commit is contained in:
slidingshade 2020-04-09 17:34:42 +03:00 committed by GitHub
parent fdac477d09
commit 3acfc416bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -37,8 +37,7 @@ class Sender:
msg.attach(mobi)
smtp = smtplib.SMTP(host=self.host, port=self.port)
smtp.starttls()
smtp = smtplib.SMTP_SSL(host=self.host, port=self.port)
if self.user is not None:
smtp.login(self.user, self.passwd)
smtp.sendmail(self.from_addr, [email], msg.as_string())