'Puts the connection to the SMTP server into TLS mode.
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first.
If the server supports TLS, this will encrypt the rest of the SMTP
session. If you provide the keyfile and certfile parameters,
the identity of the SMTP server and client can be checked. This,
however, depends on whether the socket module really checks the
certificates.
This method may raise the following exceptions:
SMTPHeloError            The server didn\'t reply properly to
the helo greeting.'

def starttls(self, keyfile=None, certfile=None):

    self.ehlo_or_helo_if_needed()
    if (not self.has_extn('starttls')):
        raise SMTPException('STARTTLS    extension    not    supported    by    server.')
    (resp, reply) = self.docmd('STARTTLS')
    if (resp == 220):
        if (not _have_ssl):
            raise RuntimeError('No    SSL    support    included    in    this    Python')
        self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
        self.file = SSLFakeFile(self.sock)
        self.helo_resp = None
        self.ehlo_resp = None
        self.esmtp_features = {}
        self.does_esmtp = 0
    else:
        raise SMTPResponseException(resp, reply)
    return (resp, reply)
