title: POP3 example from docs.python.org throws error
body: <p>So I am somewhat new to Python and was trying to create a script to download emails from my pop3 server. I found a (seemingly) simple example on Python.org but when I ran the code with my mail server settings I get this error:</p>
  
  <pre><code>Traceback (most recent call last):                           
    File "getmail.py", line 4, in &lt;module&gt;                     
      M.pass_(getpass.getpass())                               
    File "E:\Python32\lib\poplib.py", line 192, in pass_       
      return self._shortcmd('PASS %s' % pswd)                  
    File "E:\Python32\lib\poplib.py", line 155, in _shortcmd   
      return self._getresp()                                   
    File "E:\Python32\lib\poplib.py", line 131, in _getresp    
      raise error_proto(resp)                                  
  poplib.error_proto: b'-ERR Authentication failed.'            
  </code></pre>
  
  <p>Example code from python.org:</p>
  
  <pre><code>import getpass, poplib
  
  M = poplib.POP3('localhost')
  M.user(getpass.getuser())
  M.pass_(getpass.getpass())
  numMessages = len(M.list()[1])
  for i in range(numMessages):
      for j in M.retr(i+1)[1]:
          print j
  </code></pre>
  
  <p>The "print j" line throws an error of course. Curiously, the script also fails to ask for the username, only asking for a password which is where the "Authentication failed." comes from I am guessing.</p>
  
  <p>I made the following changes for my script to remove the possibility I keyed in the user/password incorrectly:</p>
  
  <pre><code>import getpass, poplib
  
  M = poplib.POP3('mail.myPOP3server.com')
  M.user = 'my_username'
  M.pass_ = 'myPassword'
  numMessages = len(M.list()[1])
  for i in range(numMessages):
      for j in M.retr(i+1)[1]:
          print(j)
  </code></pre>
  
  <p>And got the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\wos\getmail.py", line 6, in &lt;module&gt;
      numMessages = len(M.list()[1])
    File "E:\Python32\lib\poplib.py", line 219, in list
      return self._longcmd('LIST')
    File "E:\Python32\lib\poplib.py", line 162, in _longcmd
      return self._getlongresp()
    File "E:\Python32\lib\poplib.py", line 138, in _getlongresp
      resp = self._getresp()
    File "E:\Python32\lib\poplib.py", line 131, in _getresp
      raise error_proto(resp)
  poplib.error_proto: b'-ERR Unknown command.'
  [Finished in 0.4s with exit code 1]
  </code></pre>
  
  <p>So I am convinced that this is where the issue is:</p>
  
  <pre><code>numMessages = len(M.list()[1])
  </code></pre>
  
  <p>Can anyone shed some light on this? </p>
  
  <p>I use the docs.python.org regularly for example code and this is the first time I have had example code fail. I tried changing the password to something really short and simple, adding "@servername" to the username and still cannot get a list of emails.</p>
  
  <p>Example code is on this <a href="https://docs.python.org/2/library/poplib.html?highlight=retr#poplib.POP3.retr" rel="nofollow">page</a></p>
  
  <p>UPDATE: I would appreciate if the downvotes were at least explained so I can learn from the process.</p>