(self, name='')
return (code, msg)
SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
SMTP ehlo command . Hostname to send for this command defaults to the FQDN of the local host .
def ehlo(self, name=''):
        """ SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        """
        self.esmtp_features = {}
        self.putcmd(self.ehlo_msg, name or self.local_hostname)
        (code, msg) = self.getreply()
        # According to RFC1869 some (badly written)
        # MTA's will disconnect on an ehlo. Toss an exception if
        # that happens -ddm
        if code == -1 and len(msg) == 0:
            self.close()
            raise SMTPServerDisconnected("Server not connected")
        self.ehlo_resp = msg
        if code != 250:
            return (code, msg)
        self.does_esmtp = True
        #parse the ehlo response -ddm
        assert isinstance(self.ehlo_resp, bytes), repr(self.ehlo_resp)
        resp = self.ehlo_resp.decode("latin-1").split('\n')
        del resp[0]
        for each in resp:
            # To be able to communicate with as many SMTP servers as possible,
            # we have to take the old-style auth advertisement into account,
            # because:
            # 1) Else our SMTP feature parser gets confused.
            # 2) There are some servers that only advertise the auth methods we
            #    support using the old style.
            auth_match = OLDSTYLE_AUTH.match(each)
            if auth_match:
                # This doesn't remove duplicates, but that's no problem
                self.esmtp_features["auth"] = self.esmtp_features.get("auth", "") \
                        + " " + auth_match.groups(0)[0]
                continue

            # RFC 1869 requires a space between ehlo keyword and parameters.
            # It's actually stricter, in that only spaces are allowed between
            # parameters, but were not going to check for that here.  Note
            # that the space isn't present if there are no parameters.
            m = re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?', each)
            if m:
                feature = m.group("feature").lower()
                params = m.string[m.end("feature"):].strip()
                if feature == "auth":
                    self.esmtp_features[feature] = self.esmtp_features.get(feature, "") \
                            + " " + params
                else:
                    self.esmtp_features[feature] = params
        return (code, msg)
def ehlo ( self , name = '' ) : self . esmtp_features = { } self . putcmd ( self . ehlo_msg , name or self . local_hostname ) ( code , msg ) = self . getreply ( ) # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == - 1 and len ( msg ) == 0 : self . close ( ) raise SMTPServerDisconnected ( "Server not connected" ) self . ehlo_resp = msg if code != 250 : return ( code , msg ) self . does_esmtp = True #parse the ehlo response -ddm assert isinstance ( self . ehlo_resp , bytes ) , repr ( self . ehlo_resp ) resp = self . ehlo_resp . decode ( "latin-1" ) . split ( '\n' ) del resp [ 0 ] for each in resp : # To be able to communicate with as many SMTP servers as possible, # we have to take the old-style auth advertisement into account, # because: # 1) Else our SMTP feature parser gets confused. # 2) There are some servers that only advertise the auth methods we #    support using the old style. auth_match = OLDSTYLE_AUTH . match ( each ) if auth_match : # This doesn't remove duplicates, but that's no problem self . esmtp_features [ "auth" ] = self . esmtp_features . get ( "auth" , "" ) + " " + auth_match . groups ( 0 ) [ 0 ] continue # RFC 1869 requires a space between ehlo keyword and parameters. # It's actually stricter, in that only spaces are allowed between # parameters, but were not going to check for that here.  Note # that the space isn't present if there are no parameters. m = re . match ( r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?' , each ) if m : feature = m . group ( "feature" ) . lower ( ) params = m . string [ m . end ( "feature" ) : ] . strip ( ) if feature == "auth" : self . esmtp_features [ feature ] = self . esmtp_features . get ( feature , "" ) + " " + params else : self . esmtp_features [ feature ] = params return ( code , msg )