change the logic of clipping leases
[plcapi.git] / PLC / sendmail.py
index 86cee36..a215dc2 100644 (file)
@@ -35,7 +35,7 @@ def sendmail(api, To, Subject, Body, From=None, Cc=None, Bcc=None):
         Bcc = [Bcc]
     if From is None:
         From = ("%s Support" % api.config.PLC_NAME,
-                api.config.PLC_MAIL_SUPPORT_ADDRESS)
+                api.config.PLC_MAIL_FROM_ADDRESS)
 
     # Create a MIME-encoded UTF-8 message
     msg = MIMEText(Body)
@@ -93,10 +93,10 @@ def sendmail(api, To, Subject, Body, From=None, Cc=None, Bcc=None):
 
     s = SMTP()
     s.connect()
-    s.close()
     rejected = s.sendmail(
         from_addrs[0], to_addrs,
         msg.as_string(), rcpt_options=["NOTIFY=NEVER"])
+    s.quit()
 
     if rejected:
         raise PLCAPIError("Error sending message to "