catch SMTP exception if any - issue #311

This commit is contained in:
Bernardo Damele 2013-01-18 13:46:50 +00:00
parent 3dd9f29938
commit fb752e6936

View File

@ -91,7 +91,11 @@ if CONTENT:
attachment.add_header("Content-Disposition", "attachment", filename="test_case_%d_console_output.txt" % test_count) attachment.add_header("Content-Disposition", "attachment", filename="test_case_%d_console_output.txt" % test_count)
msg.attach(attachment) msg.attach(attachment)
try:
s = smtplib.SMTP(host=SMTP_SERVER, port=SMTP_PORT, timeout=SMTP_TIMEOUT) s = smtplib.SMTP(host=SMTP_SERVER, port=SMTP_PORT, timeout=SMTP_TIMEOUT)
#s.set_debuglevel(1) #s.set_debuglevel(1)
s.sendmail(FROM, TO, msg.as_string()) s.sendmail(FROM, TO, msg.as_string())
s.quit() s.quit()
# Catch all for SMTP exceptions
except smtplib.SMTPException, e:
print "Failure to send email: %s" % str(e)