Example #1
0
 def get_context_data(self, *args, **kwargs):
     context = super(MailView, self).get_context_data(*args, **kwargs)
     conn = open_imap_connection(self.request)
     type, data = conn.list()
     conn.logout()
     tree = parse_list(data)
     context.update({
         'folders': tree,
     })
     return context
Example #2
0
    def get_queryset(self):
        # Grab the msg count and the msg ids from the mailserver
        self.conn = open_imap_connection(self.request)
        type, msg_total = self.conn.select(str(self.get_mailbox()))
        type, msg_ids = self.conn.search(None, 'ALL')

        # Split the ids into an iterable list
        msg_ids_list = msg_ids[0].split()
        # reverse it so the new older messages end up at the end
        # of the list
        msg_ids_list.reverse()
        return msg_total, msg_ids_list