print("Before try-except block") # Отладочное выражение
# Отправка письма
try:
server = smtplib.SMTP_SSL('smtp.yandex.ru', 465)
server.ehlo()
server.login(email_user, email_password)
server.sendmail(email_user, email_receiver, message.encode('utf-8'))
server.close()
print('Email sent!')
except Exception as e:
print('Something went wrong:', e)
print("After try-except block") # Отладочное выражение