Search Results

Search found 6 results on 1 pages for 'imaplib'.

Page 1/1 | 1 

  • How do you iterate through each email in your inbox using python?

    - by djblue2009
    I'm completely new to programming and I'm trying to build an autorespoder to send a msg to a specific email address. Using an if statement, I can check if there is an email from a certain address in the inbox and I can send an email, but if there are multiple emails from that address, how can I make a for loop to send an email for every email from that specific address. I tried to do use this as a loop: for M.search(None, 'From', address) in M.select(): but I get the error: "can't assign to function call" on that line

    Read the article

  • Fetch Subject & sender in IMAP

    - by shadyabhi
    After the following code:- import imaplib conn = imaplib.IMAP4("mail.daiict.ac.in") conn.login("200801076","mypass") # OUT: ('OK', ['Logged in.']) conn.select() # OUT: ('OK', ['166']) Now, how do I fetch the sender and subject of mails in the inbox?

    Read the article

  • Forwarding an email with python smtplib

    - by robbles
    I'm trying to put together a script that automatically forwards certain emails that match a specific criteria to another email. I've got the downloading and parsing of messages using imaplib and email working, but I can't figure out how to forward an entire email to another address. Do I need to build a new message from scratch, or can I somehow modify the old one and re-send it? Here's what I have so far (client is an imaplib.IMAP4 connection, and id is a message ID): status, data = client.fetch(id, '(RFC822)') email_body = data[0][1] mail = email.message_from_string(email_body) # ...Process message... # This doesn't work forward = email.message.Message() forward.set_payload(mail.get_payload()) forward['From'] = '[email protected]' forward['To'] = '[email protected]' smtp.sendmail(user, ['[email protected]'], forward.as_string()) I'm sure there's something slightly more complicated I need to be doing with regard to the MIME content of the message. Surely there's some simple way of just forwarding the entire message though? # This doesn't work either, it just freezes...? mail['From'] = '[email protected]' mail['To'] = '[email protected]' smtp.sendmail(user, ['[email protected]'], mail.as_string())

    Read the article

1