title: Can't get emails in Drafts, Spam and Trash folders from google using javax.mail
body: <p>I want to get emails from all folders from gmail.
  From inbox, sent and other folders I receive emails successfully.
  But when I try to get it from Drafts, Spam and Trash I get an exception:</p>
  
  <pre><code>09:51:45,622 ERROR MailRetriever.[main]getNoFlaggedMails:142 - Can't get messages: javax.mail.MessagingException: connection failure
  javax.mail.MessagingException: connection failure
  at com.sun.mail.imap.IMAPStore.getProtocol(IMAPStore.java:742)
  at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:910)
  at ua.com.stormlabs.gap.gmail.MailRetriever.getNoFlaggedMails(MailRetriever.java:133)
  at ua.com.stormlabs.gap.gmail.GMailServiceProcessor.processFolder(GMailServiceProcessor.java:95)
  at ua.com.stormlabs.gap.gmail.GMailServiceProcessor.start(GMailServiceProcessor.java:80)
  at ua.com.stormlabs.gap.gmail.GMailGapApp.main(GMailGapApp.java:21)
  </code></pre>
  
  <p>This is code for retrieving mails:</p>
  
  <pre><code>Folder folder = imapSslStore.getFolder(folderName);
  folder.open(Folder.READ_WRITE);
  openedFolders.put(folderName, folder);
  
  Flags searchFlags = new Flags(Flags.Flag.USER);
  searchFlags.add(FLAG_PREFIX + READ_BY_GAP_FLAG);
  Message[] messages = folder.search(new FlagTerm(searchFlags, false));
  log.debug("Messages list retrieved: " + messages.length);
  return messages;
  </code></pre>
  
  <p>Folder names I try to open unsuccessfully:</p>
  
  <pre><code>[Gmail]/Drafts
  [Gmail]/Spam
  [Gmail]/Trash
  </code></pre>