Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing imaplib to log into Gmail using credentials from a file
    primarykey
    data
    text
    <p>I apologise in advance, I know this will be a simple answer but I'm not having any luck and it's starting to bug me.</p> <p>I just want to log into my Gmail account using imaplib and credentials pulled from a file. I can log into Gmail no worries using:</p> <pre><code>srv = imaplib.IMAP_SSL("imap.gmail.com") srv.login("bob@gmail.com", "mypassword") </code></pre> <p>But instead I'm trying to use a text file (credentials.dat). Inside the file is 2 lines:</p> <pre><code>bob@gmail.com mypassword </code></pre> <p>My code is as follows:</p> <pre><code>import imaplib CREDS = open("credentials.dat", "r") account = CREDS.readline() password = CREDS.readline() srv = imaplib.IMAP4_SSL("imap.gmail.com") srv.login(account, password) </code></pre> <p>When I run it I get the followign error:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in ? File "/usr/lib64/python2.4/imaplib.py", line 480, in login typ, dat = self._simple_command('LOGIN', user, self._quote(password)) File "/usr/lib64/python2.4/imaplib.py", line 1028, in _simple_command return self._command_complete(name, self._command(name, *args)) File "/usr/lib64/python2.4/imaplib.py", line 865, in _command_complete raise self.error('%s command error: %s %s' % (name, typ, data)) imaplib.error: LOGIN command error: BAD ['Failed to parse your command r13if7033890ebd.47'] </code></pre> <p>I assume it doesn't like the data type being entered into srv.login, but I have no idea how else to do it.</p> <p>There are so many more things I want to do once I get into Gmail (read emails, post, etc), but it's looking like an uphill battle if I can't even log in :( </p> <p>Thanks for your time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload