smtplib.SMTP_SSL.starttls

SMTP_SSL.starttls(keyfile=None, certfile=None)

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.