Beispiel #1
0
if 'imap.gmail.com' in mailbox_server.servername:
    if options.cachefile is None:
        print >> sys.stdout, "Gmail Mailboxes require a cache"
        sys.exit(1)
    else:
        cache = GmailCache(mailbox_server)
        cache.load(options.cachefile)
        cache.autosave = options.cachefile
        cache.update()


for mailbox_name in args[2:]:
    mailbox =  ImapMailbox((mailbox_server.clone(), mailbox_name))
    print("\n\nProcessing mailbox %s" % mailbox.name)
    encrypted = mailbox.search('UNDELETED HEADER Content-Type encrypted')
    for uid in encrypted:
        print("    Decrypting UID %s" % uid)
        message = mailbox[uid]
        labels = [mailbox_name] # all the mailboxes the mail appears (for gmail)
        if options.backup is not None:
            print("        Backing up the original (encrypted) message")
            backupbox.add(message)
        print("        Deleting the original (encrypted) message")
        if is_gmail_box(mailbox):
            labels = cache.get_labels("%s.%s" % (mailbox_name, uid))
            delete(mailbox, uid)
        else:
            mailbox.discard(uid)
        print("        Piping message through decryption program")
        try:
Beispiel #2
0
    pass

record_file = open(options.record, 'a')
mailbox = None
try:
    for label in labels:
        if not label in include: continue
        if label in exclude: continue
        if mailbox is None:
            mailbox = ImapMailbox((server, label))
        else:
            mailbox.switch(label)
        if options.search == '':
            uids = mailbox.get_all_uids()
        else:
            uids = mailbox.search(options.search)
        for uid in uids:
            if not record.has_key("%s.%s" % (label, uid)):
                descr = "%s.%s " % (label, uid)
                if options.summary:
                    s = summary(mailbox, uid, printuid=False, printout=False)[0]
                    descr += "\t" + s[3:]
                print descr
except KeyboardInterrupt:
    print ""
except Exception, errormessage:
    if options.raise_exception: raise
    print "Program ended with exception. Run again."
    print errormessage

record_file.close()