<p>tldr:  Can someone show me how to properly format this Python iMAP example so it works?</p>

<p>from 
<a href="https://docs.python.org/2.4/lib/imap4-example.html" rel="nofollow noreferrer">https://docs.python.org/2.4/lib/imap4-example.html</a></p>

<blockquote>
<pre><code>import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print 'Message %s\n%s\n' % (num, data[0][1])
M.close()
M.logout()
</code></pre>
</blockquote>

<p>Assuming my email is "email@gmail.com" and the password is "password," how should this look?  I tried <code>M.login(getpass.getuser(email@gmail.com), getpass.getpass(password))</code>
and it timed out.  Complete newb here, so it's very likely I missed something obvious (like creating an iMAP object first?  Not sure).</p>

Did you forget to specify the IMAP host and port? Use something to the effect of:
```
```
M = imaplib.IMAP4_SSL( 'imap.gmail.com' )
```
```
or,
```
```
M = imaplib.IMAP4_SSL()
M.open( 'imap.gmail.com' )
```
```