title: IMAP python - proper method of storing user authorization data
body: <p>I am working on an email client powered by Django and <a href="http://imapclient.readthedocs.io/en/master/" rel="nofollow noreferrer">IMAPClient library</a>.
  On the client-side, users have interface for associating their mailboxes (like <code>test1@gmail.com</code>, <code>test2@gmail.com</code>, etc...) with their accounts in my app . And the goal is to store credentials info so that the user has to go through the procedure of inserting password and host name (like <code>imap.gmail.com</code>) only once unless he deliverately logs out from an account. </p>
  
  <p>The question is, where and how should the login/password/hostname data used for establishing IMAP connection be stored? Is it my server's DB? Or some sort of <code>.ini</code> files? I remember, reading a post about python/imap where they stored it in <code>.ini</code> files, but I can't find it now.  </p>
  
  <p>Currently, I store credentials and IMAP hostname info in my local db. Thus, in each view that needs to fetch info from IMAP server, I query my server db to get the data and After this, I initialize IMAPClient variable for establishing connection with the IMAP server. And I have a terrible feeling that this is junk code:</p>
  
  <pre><code>def show_mail(request, login):
      user_email_info = UserEmailInfo.objects.get(user_id = request.user.id,
                                                  login = login)
      HOST = user_email_info.host #'imap.gmail.com'
      USERNAME = user_email_info.login
      PASSWORD = user_email_info.psw 
      server = IMAPClient(HOST, use_uid=True, ssl=True)
      server.login(USERNAME, PASSWORD)
  </code></pre>
  
  <p>P.S. I am not sure whether this question is related more to general python/Django rather than IMAP. So if I am missing something, please give a hint on this, I'll edit the question in a timely manner.</p>