I want to send an e-mail with an attached CSV file. Currently, the script looks like this:
#!/usr/bin/python3 # -*- Coding: utf-8 -*- import smtplib server = smtplib.SMTP('smtp.yandex.ru', 465) server.starttls() server.login('my_login', 'my_password') msg = "YOUR MESSAGE!" server.sendmail("my@email.com", "from@email.ru", msg.as_string()) server.quit() So far without an attachment, just potestit the fact of sending via external SMTP. The question is: when I run the script in the console, nothing happens. No mistakes, nothing. And the invitation to enter also does not appear. Well .. that is, the script pretends that some kind of long hard work is underway. I interrupt on Ctrl + C. The letter, accordingly, does not come. The question is what happens at this moment, where and how can I catch the error?
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out- Captain Flintmtr smtp.yandex.rucommand (or equivalent). - jfs