From 16a3ba69520bfb4d57c4ac0d3c16cc6521058e41 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 22 Jan 2013 21:11:00 +0100 Subject: catch the potential exceptions when sending e-mail via smtp. --- source/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/utils.py b/source/utils.py index f2756286..577304db 100755 --- a/source/utils.py +++ b/source/utils.py @@ -171,13 +171,13 @@ def send_mail(mfrom, mto, feed_title, article_title, description): try: s = smtplib.SMTP(conf.smtp_server) s.login(conf.username, conf.password) - except: - print("smtp error") + # sendmail function takes 3 arguments: sender's address, recipient's address + # and message to send - here it is sent as one string. + s.sendmail(mfrom, mto, msg.as_string()) + s.quit() + except Exception as e: + print(e) return - # sendmail function takes 3 arguments: sender's address, recipient's address - # and message to send - here it is sent as one string. - s.sendmail(mfrom, mto, msg.as_string()) - s.quit() def add_feed(feed_url): """ -- cgit