In one company I worked with, we have a mailbox for offers with websites that have “adult” material and one spam mailbox that should be blocked. As soon as I started working, I was “charged” with this “gracious” work. Checking this, there was something like 2,000 unread emails to block and 4,000 spam emails to block. Of course, this is a feature that needs to be automated, and I was looking for a good solution for me. What I've done:
[1] Using python IMAP to connect to the Exchange server [2] Using beatifulsoup (python) to analyze href values inside an email [3] After that send an email with thanks for its cooperation (very important)
Three days after my boss thanked me for my great efforts, I answered all emails and we received compliments. Because NOW we are responsible for customers. (not me script)
Ok now let's make a plan
- Check the imap module python [1] and then take one tutorial using ssl imap4 [4]
- Decide which is best for YOUR problem? Download emails (pop3) or search and browse it on the server (IMAP).
- CHECK if you can connect using IMAP4 or POP3 protocols. Before, the exchange will be an error in this part, please also check this error report [3]
- Well, you are sure that you can connect using IMAP4 or POP3, now you will receive one message and analyze it using a beautiful soup or lxml. (in my case, I was looking for href and 'mailto:')
- Make a good message using the 'from:' field, by email, by making it personal.
- PROFIT
[1] google it imap python
[2] google it BeautifulSoup python
[3] http://support.microsoft.com/kb/296387
[4] http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/
Sorry, but I had to provide google urls because of my low score.
I hope this answer gives you some good recommendations for your solution. Of course, you can make it more hax0r using lxml by sending data to the database. But after you connect and start to manipulate, you can do anything :)
Carlos Henrique Cano
source share