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 <dennis@ausil.us>
This commit is contained in:
parent
55d57495d3
commit
60f0859591
1 changed files with 6 additions and 3 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue