title: Problems with IMAP in Gmail with Python
body: <p>I have a problem with IMAP in Python  2.7
  For testing purposes, I have created <code>foobar306@gmail.com</code> with the password <code>testing123testing</code>
  I am following <a href="http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/" rel="nofollow">this tutorial</a> and typed this into my Python Iteractive Shell:</p>
  
  <pre><code>    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
  Type "copyright", "credits" or "license()" for more information.
  &gt;&gt;&gt; import imaplib
  mail = imaplib.IMAP4_SSL('imap.gmail.com')
  mail.login('foobar306@gmail.com', 'testing123testing')
  mail.list()
  # Out: list of "folders" aka labels in gmail.
  mail.select("inbox") # connect to inbox.
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Nothing happens, not even error messages.
  Note: I have enabled IMAP in Gmail
  Thanks, -tim</p>
  
  <p>Update: In response to this comment:</p>
  
  <blockquote>
    <p>Did you do the next section after the code you quoted above? – Amber </p>
  </blockquote>
  
  <p>I tried this: </p>
  
  <pre><code>    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
  Type "copyright", "credits" or "license()" for more information.
  &gt;&gt;&gt; import imaplib
  mail = imaplib.IMAP4_SSL('imap.gmail.com')
  mail.login('myusername@gmail.com', 'mypassword')
  mail.list()
  # Out: list of "folders" aka labels in gmail.
  mail.select("inbox") # connect to inbox.
  result, data = mail.search(None, "ALL")
  
  ids = data[0] # data is a list.
  id_list = ids.split() # ids is a space separated string
  latest_email_id = id_list[-1] # get the latest
  
  result, data = mail.fetch(latest_email_id, "(RFC822)") # fetch the email body (RFC822) for the given ID
  
  raw_email = data[0] # here's the body, which is raw text of the whole email
  # including headers and alternate payloads
  
  &gt;&gt;&gt;
  </code></pre>
  
  <p>and it still did nothing</p>