'Close the connection to the SMTP server.'

def close(self):

    try:
        file = self.file
        self.file = None
        if file:
            file.close()
    finally:
        sock = self.sock
        self.sock = None
        if sock:
            sock.close()
