~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smtp_connection.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-23 07:15:13 UTC
  • mfrom: (2926 +trunk)
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071023071513-elryt6g2at34d2ur
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
            else:
83
83
                raise
84
84
 
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
87
 
        # to fail anyway).
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))
 
91
 
 
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))
89
101
 
90
102
    def _authenticate(self):
91
103
        """If necessary authenticate yourself to the server."""