Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8310769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:34:49+00:00 2026-06-08T19:34:49+00:00

I am trying to access to my emails in Gmail from a python script.

  • 0

I am trying to access to my emails in Gmail from a python script. The code I use is the following:

import imaplib
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login("username","password")
m.select("[Gmail]/All Mail")

When running this code in python 2, it works fine, I get the list of all my emails. In python 3 hoverer it fails with the error

>>> m.select("[Gmail]/All Mail")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/imaplib.py", line 674, in select
    typ, dat = self._simple_command(name, mailbox)
  File "/usr/lib/python3.2/imaplib.py", line 1121, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python3.2/imaplib.py", line 957, in _command_complete
    raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: SELECT command error: BAD [b'[CLIENTBUG] Too many arguments for command']

I have done a bit of testing. It works fine on other folder such as “Inbox” where I get only 400 emails (vs 6000 in “All Mail”).

Is it a problem related to the size of the list ? Why is it different in python 2 and 3 ?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:34:52+00:00Added an answer on June 8, 2026 at 7:34 pm

    Try using m.select('"[Gmail]/All Mail"'), so that the double quotes get transmitted.

    I suspect imaplib is not properly quoting the string, so the server gets what looks like two arguments: [Gmail]/All and Mail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access emails from Gmail accounts through IMAP with the help
I am trying to access an exchange server to read emails from a specific
I am trying to access my Gmail account through PHP. I tried code like
I am trying to use the following code, which I have not been able
I'm trying to get the contacts from Outlook (2007) using the following code: Outlook.Application
Trying to access a Servlet from a button on HTML page //Html Page FORM
I am trying to access all the data from database listOfFolder table folder and
I'm trying to access the resources of a derived abstract class (from PhoneApplicationPage) in
For testing purposes, I am trying to send emails to hello@test.com , but qmail
I am trying to access the HTML code source of AJAX dynamically loaded content.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.