Skip to content

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

Closed

Description

@hdvision
mannequin
BPO 6328
Nosy @bitdancer
Dependencies
  • bpo-5259: smtplib is broken in Python3
  • Files
  • python-shot.png: screen shot of python debugger
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-06-23.16:21:49.892>
    created_at = <Date 2009-06-23.16:05:25.991>
    labels = ['type-bug', 'library']
    title = 'login() function failed in smtplib with message "argument 1 must be bytes or buffer, not str"'
    updated_at = <Date 2009-06-23.16:21:49.865>
    user = 'https://bugs.python.org/hdvision'

    bugs.python.org fields:

    activity = <Date 2009-06-23.16:21:49.865>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-06-23.16:21:49.892>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2009-06-23.16:05:25.991>
    creator = 'hdvision'
    dependencies = ['5259']
    files = ['14342']
    hgrepos = []
    issue_num = 6328
    keywords = []
    message_count = 2.0
    messages = ['89629', '89631']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'hdvision']
    pr_nums = []
    priority = 'low'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6328'
    versions = ['Python 3.0']

    Activity

    1. hdvision commented on Jun 23, 2009

      hdvisionmannequin
      MannequinAuthor

      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

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Jun 23, 2009
    3. bitdancer commented on Jun 23, 2009

      @bitdancer
      Member

      This is a duplicate of bpo-5259, and has been fixed in 3.1.

    4. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 23, 2009
    5. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Jun 23, 2009
    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions