Example #1
0
def connect ():
	try: 
		m = imaplib.IMAP4_SSL(config.get_net("HOST"), int(config.get_net("PORT")))
		m.login(config.get_net("USER"), getpass.getpass())
		return m
	except imaplib.IMAP4.error as e:
		print (e.args[0])
		sys.exit(1)
def connect():
    try:
        m = imaplib.IMAP4_SSL(config.get_net("HOST"),
                              int(config.get_net("PORT")))
        m.login(config.get_net("USER"), getpass.getpass())
        return m
    except imaplib.IMAP4.error as e:
        print(e.args[0])
        sys.exit(1)
def get_mail():
    m = connect()

    # downloads spam
    msgs = fetch_all(m, config.get_net("SPAM_SRC"))
    _write_msgs(msgs, config.get_net("SPAM_DEST"))

    msgs = fetch_all(m, config.get_net("INBOX_SRC"))
    _write_msgs(msgs, config.get_net("INBOX_DEST"))

    m.logout()
Example #4
0
def get_mail ():
    m = connect ()

    # downloads spam
    msgs = fetch_all (m, config.get_net("SPAM_SRC"))
    _write_msgs (msgs, config.get_net("SPAM_DEST"))

    msgs = fetch_all (m, config.get_net("INBOX_SRC"))
    _write_msgs (msgs, config.get_net("INBOX_DEST"))

    m.logout()
def write_msg_to_spam(m, mid):
    try:
        # copies the message
        m.copy(mid, config.get_net("SPAM_SRC"))
        m.store(mid, '+FLAGS', '\\Deleted')
    except imaplib.IMAP4.error as e:
        print e.args[0]
        m.logout()
        sys.exit(1)
Example #6
0
def write_msg_to_spam (m, mid):
    try:
        # copies the message
        m.copy (mid, config.get_net("SPAM_SRC"))
        m.store (mid, '+FLAGS', '\\Deleted')
    except imaplib.IMAP4.error as e:
        print e.args[0]
        m.logout()
        sys.exit(1)