[issue6328] login() function failed in smtplib with message "argument 1 must be bytes or buffer, not str"

Gehua Yang report at bugs.python.org
Tue Jun 23 18:05:27 CEST 2009


New submission from Gehua Yang <yanggehua at gmail.com>:

Hi folks,

I encountered the following error with this Python code snippet. (I ran
it with Python 3.0.1). Judging from the error as shown in IDLE debugger,
the error was buried inside python. 

  try:
    server = smtplib.SMTP(EmailConfig.smtpServerName)
    server.set_debuglevel(3)
    print(server)
    server.login(bytes(EmailConfig.mailUser, encoding='ascii'),
bytes(EmailConfig.mailPass, encoding='ascii'))
    print('Login is successful.')
    failed = server.sendmail(from_addr, to_addr, text_msg)
  except Exception as ex:
    print('Error in communicating with SMTP server', ex)
  else:
    if failed : print('Failed in sending email with following
reason:\n', failed)


***********************************************
The output from terminal is:
$ c:/tools/Python30/python send_email.py
<smtplib.SMTP object at 0x00F21990>
send: 'ehlo quad-vision.hua\r\n'
reply: b'250-smtp.mxes.net\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 400000000\r\n'
reply: b'250-ETRN\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250-AUTH PLAIN LOGIN\r\n'
reply: b'250-AUTH=PLAIN LOGIN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250 DSN\r\n'
reply: retcode (250); Msg: b'smtp.mxes.net\nPIPELINING\nSIZE
400000000\nETRN\nSTARTTLS\nAUTH PLAIN L
OGIN\nAUTH=PLAIN LOGIN\nENHANCEDSTATUSCODES\n8BITMIME\nDSN'
Error in communicating with SMTP server b2a_base64() argument 1 must be
bytes or buffer, not str

----------
files: python-shot.png
messages: 89629
nosy: hdvision
severity: normal
status: open
title: login() function failed in smtplib with message "argument 1 must be bytes or buffer, not str"
type: crash
versions: Python 3.0
Added file: http://bugs.python.org/file14342/python-shot.png

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6328>
_______________________________________


More information about the Python-bugs-list mailing list