Python2.6 SMTP.close() fails when instance never connected.

This commit is contained in:
Stuart Gathman
2011-03-18 20:41:31 +00:00
parent 5290bc0668
commit eef3cde27e
+4 -1
View File
@@ -5,6 +5,9 @@
# Send DSNs, do call back verification, # Send DSNs, do call back verification,
# and generate DSN messages from a template # and generate DSN messages from a template
# $Log$ # $Log$
# Revision 1.21 2011/03/03 05:11:58 customdesigned
# Release 0.9.4
#
# Revision 1.20 2010/10/11 00:29:47 customdesigned # Revision 1.20 2010/10/11 00:29:47 customdesigned
# Handle multiple recipients. For CBV or auto whitelist of multiple emails. # Handle multiple recipients. For CBV or auto whitelist of multiple emails.
# #
@@ -149,7 +152,7 @@ def send_dsn(mailfrom,receiver,msg=None,timeout=600,session=None,ourfrom=''):
pass # MX didn't accept connections, try next one pass # MX didn't accept connections, try next one
except socket.timeout: except socket.timeout:
pass # MX too slow, try next one pass # MX too slow, try next one
smtp.close() if hasattr(smtp,'sock'): smtp.close()
if time.time() > toolate: if time.time() > toolate:
return (450,'No MX response within %f minutes'%(timeout/60.0)) return (450,'No MX response within %f minutes'%(timeout/60.0))
return (450,'No MX servers available') # temp error return (450,'No MX servers available') # temp error