From 60f085959194f0626b600c3582401b256cf91cf9 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Feb 22 2017 16:27:46 +0000 Subject: wrap sending email in try except Sometimes the recipient email may no longer be valid due to many reasons. Handle the failure to send email gracefully. Signed-off-by: Dennis Gilmore --- diff --git a/util/koji-gc b/util/koji-gc index fd4aa26..426c2f3 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -419,9 +419,12 @@ refer to the document linked above for instructions.""" else: if options.debug: print "Sending warning notice to %s" % msg['To'] - s = smtplib.SMTP(options.smtp_host) - s.sendmail(msg['From'], msg['To'], msg.as_string()) - s.quit() + try: + s = smtplib.SMTP(options.smtp_host) + s.sendmail(msg['From'], msg['To'], msg.as_string()) + s.quit() + except: + print "FAILED: Sending warning notice to %s" % msg['To'] def main(args):