Created
December 1, 2015 22:19
-
-
Save barik/3b36a54e9d0b27151f23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imaplib | |
HOST = "mail.messagingengine.com" | |
USER = "[email protected]" | |
PASSWORD = "password" | |
BATCH_FOLDER = "INBOX.Batch" | |
INBOX_FOLDER = "INBOX" | |
def batch_mail(): | |
server = imaplib.IMAP4_SSL(HOST) | |
server.login(USER, PASSWORD) | |
server.select(BATCH_FOLDER) | |
typ, [msg_uids] = server.uid("SEARCH", "ALL") | |
msg_uids = ",".join(msg_uids.split(" ")) | |
if msg_uids: | |
server.uid("COPY", msg_uids, INBOX_FOLDER) | |
server.uid("STORE", msg_uids, "+FLAGS.SILENT", r"(\Deleted)") | |
server.uid("EXPUNGE", msg_uids) | |
return msg_uids | |
# noinspection PyUnusedLocal | |
def lambda_handler(event, context): | |
return batch_mail() | |
if __name__ == '__main__': | |
batch_mail() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment