How can I fetch emails via POP or IMAP through a proxy?

You don’t need to dirtily hack imaplib. You could try using the SocksiPy package, which supports socks4, socks5 and http proxy (connect): Something like this, obviously you’d want to handle the setproxy options better, via extra arguments to a custom __init__ method, etc. from imaplib import IMAP4, IMAP4_SSL, IMAP4_PORT, IMAP4_SSL_PORT from socks import sockssocket, PROXY_TYPE_SOCKS4, … Read more

Downloading multiple attachments using imaplib

For any future python travellers. Here is a class that downloads any attachment found for an email and saves it to a specific location. import email import imaplib import os class FetchEmail(): connection = None error = None def __init__(self, mail_server, username, password): self.connection = imaplib.IMAP4_SSL(mail_server) self.connection.login(username, password) self.connection.select(readonly=False) # so we can mark mails … Read more

What are the “parts” in a multipart email?

An email message consists of a single MIME part, or a multipart structure with multiple MIME parts. If there is no multipart structure, the message is compatible with pre-MIME RFC822 messages, and the Content-type: etc headers are optional (if you don’t spell out a content type and encoding, Content-type: text/plain; charset=”us-ascii” and Content-transfer-encoding: 7bit are … Read more

Getting mail from GMail into Java application using IMAP

Using imaps was a great suggestion. Neither of the answers provided just worked for me, so I googled some more and found something that worked. Here’s how my code looks now. Properties props = System.getProperties(); props.setProperty(“mail.store.protocol”, “imaps”); try { Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(“imaps”); store.connect(“imap.gmail.com”, “<username>@gmail.com”, “<password>”); … } catch (NoSuchProviderException … Read more

Accessing Imap in C# [closed]

I’ve been searching for an IMAP solution for a while now, and after trying quite a few, I’m going with AE.Net.Mail. You can download the code by going to the Code tab and click the small ‘Download’ icon. As the author does not provide any pre-built downloads, you must compile it yourself. (I believe you … Read more