<p>Here was my response to Pan, it should be helpful for you two as well.</p>
<p>You will need to change the spec for .netrc, not just python&#39;s implementation.</p>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: &quot;Leif Walsh&quot; &lt;<a href="mailto:leif.walsh@gmail.com">leif.walsh@gmail.com</a>&gt;<br>Date: Mar 21, 2011 9:27 AM<br>Subject: Re: ~/.netrc &amp; multiple accounts with same @domain<br>
To: &quot;Pan Tsu&quot; &lt;<a href="mailto:inyaoo@gmail.com">inyaoo@gmail.com</a>&gt;<br><br type="attribution"><p>You can&#39;t use .netrc for both, this is a .netrc limitation, that is, it keys entries by machine name, not (machine name, user). I suggest a password file, that&#39;s what I use.</p>
<div class="elided-text">
<div class="gmail_quote">On Mar 21, 2011 6:17 AM, &quot;Pan Tsu&quot; &lt;<a href="mailto:inyaoo@gmail.com" target="_blank">inyaoo@gmail.com</a>&gt; wrote:<br type="attribution">&gt; offlineimap is unable to get password from ~/.netrc when it contains<br>

&gt; more than one entry for `machine&#39;<br>&gt; <br>&gt;   machine <a href="http://imap.gmail.com" target="_blank">imap.gmail.com</a> login foo password blah<br>&gt;   machine <a href="http://imap.gmail.com" target="_blank">imap.gmail.com</a> login bar password blah<br>

&gt; <br>&gt; where the last one wins, i.e. `bar&#39;. It&#39;ll ask password for `foo&#39;<br>&gt; account when running in TTY.TTYUI.<br>&gt; <br>&gt; OTOH, msmtp which I use to send mails picks the right password without issues.<br>

&gt; <br>&gt; --<br>&gt; $ offlineimap --version<br>&gt; 6.3.2<br>&gt; <br>&gt; _______________________________________________<br>&gt; OfflineIMAP-project mailing list<br>&gt; <a href="mailto:OfflineIMAP-project@lists.alioth.debian.org" target="_blank">OfflineIMAP-project@lists.alioth.debian.org</a><br>

&gt; <a href="http://lists.alioth.debian.org/mailman/listinfo/offlineimap-project" target="_blank">http://lists.alioth.debian.org/mailman/listinfo/offlineimap-project</a><br>&gt; <br>&gt; OfflineIMAP homepage: <a href="http://software.complete.org/offlineimap" target="_blank">http://software.complete.org/offlineimap</a><br>

</div>
</div></div>