Index: Lib/smtplib.py =================================================================== --- Lib/smtplib.py (revision 71798) +++ Lib/smtplib.py (working copy) @@ -452,6 +452,7 @@ optionlist = '' if options and self.does_esmtp: optionlist = ' ' + ' '.join(options) + sender = sender.decode() self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist)) return self.getreply() @@ -545,7 +546,8 @@ return encode_base64(response) def encode_plain(user, password): - return encode_base64("\0%s\0%s" % (user, password)) + b0 = b"\0" + return encode_base64(b0 + b0.join(user + password)) AUTH_PLAIN = "PLAIN" @@ -580,7 +582,7 @@ (code, resp) = self.docmd(encode_cram_md5(resp, user, password)) elif authmethod == AUTH_PLAIN: (code, resp) = self.docmd("AUTH", - AUTH_PLAIN + " " + encode_plain(user, password)) + AUTH_PLAIN + " " + encode_plain(user, password)[:-1]) elif authmethod == AUTH_LOGIN: (code, resp) = self.docmd("AUTH", "%s %s" % (AUTH_LOGIN, encode_base64(user)))