85
# If this fails, it just returns an error, but it shouldn't raise an
86
# exception unless something goes really wrong (in which case we want
88
self._connection.starttls()
85
# Say EHLO (falling back to HELO) to query the server's features.
86
code, resp = self._connection.ehlo()
87
if not (200 <= code <= 299):
88
code, resp = self._connection.helo()
89
if not (200 <= code <= 299):
90
raise SMTPError("server refused HELO: %d %s" % (code, resp))
92
# Use TLS if the server advertised it:
93
if self._connection.has_extn("starttls"):
94
code, resp = self._connection.starttls()
95
if not (200 <= code <= 299):
96
raise SMTPError("server refused STARTTLS: %d %s" % (code, resp))
97
# Say EHLO again, to check for newly revealed features
98
code, resp = self._connection.ehlo()
99
if not (200 <= code <= 299):
100
raise SMTPError("server refused EHLO: %d %s" % (code, resp))
90
102
def _authenticate(self):
91
103
"""If necessary authenticate yourself to the server."""