imap

Office 365 IMAP authentication via OAuth2 and python MSAL library

Office 365 IMAP authentication via OAuth2 and python MSAL library Question: I’m trying to upgrade a legacy mail bot to authenticate via Oauth2 instead of Basic authentication, as it’s now deprecated two days from now. The document states applications can retain their original logic, while swapping out only the authentication bit Application developers who have …

Total answers: 3

how i get mails from gmail over imap with python

how i get mails from gmail over imap with python Question: This is my script, the auth_string is right, i tryed this smtplib.SMTP(‘smtp.gmail.com:587’) and its worked, imap is activ in my gmail settings, and yes, please help me 🙂 def command_to_url(command): return ‘%s/%s’ % (GOOGLE_ACCOUNTS_BASE_URL, command) def call_refresh_token(client_id, client_secret, refresh_token): params = {} params[‘client_id’] = …

Total answers: 2

Python – Searching different imap inboxes based on conditions

Python – Searching different imap inboxes based on conditions Question: Is there a way to search different Inboxes based on a condition with the python imap4-library? I simply can’t wrap my head around a way to check certain subfolders based on a condition. Until now I’m selecting the subfolders from “Inbox” like this: imap = …

Total answers: 4

search criteria of IMAP protocol search command

search criteria of IMAP protocol search command Question: I read from here: http://docs.python.org/2/library/imaplib.html IMAP4.search(charset, criterion[, …]) that imaplib has the search method for me to search mails from my mail boxes. But I don’t understand what criterion are available, or is it that I can enter anything for it? I searched that page,, but didn’t …

Total answers: 3

IMAP get sender name and body text?

IMAP get sender name and body text? Question: I am using this code: import imaplib mail = imaplib.IMAP4_SSL(‘imap.gmail.com’) mail.login(myusername, mypassword) mail.list() # Out: list of “folders” aka labels in gmail. mail.select(“inbox”) # connect to inbox. result, data = mail.search(None, “ALL”) ids = data[0] # data is a list. id_list = ids.split() # ids is a …

Total answers: 3

python imaplib – mark email as unread or unseen

python imaplib – mark email as unread or unseen Question: Searching here and on the internet, there are a lot of examples to how to mark a message as SEEN, even though this is automatic with imap. But how can I mark an email as UNSEEN or UNREAD. I have a script in python which …

Total answers: 5

How to understand the equal sign '=' symbol in IMAP email text?

How to understand the equal sign '=' symbol in IMAP email text? Question: I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky – the equal sign ‘=’. It is not a normal equal sign …

Total answers: 1

How hard is it to build an Email client? – Python

How hard is it to build an Email client? – Python Question: I’m venturing in unknown territory here… I am trying to work out how hard it could be to implement an Email client using Python: Email retrieval Email sending Email formatting Email rendering Also I’m wondering if all protocols are easy/hard to support e.g. …

Total answers: 5

Getting n most recent emails using IMAP and Python

Getting n most recent emails using IMAP and Python Question: I’m looking to return the n (most likely 10) most recent emails from an email accounts inbox using IMAP. So far I’ve cobbled together: import imaplib from email.parser import HeaderParser M = imaplib.IMAP4_SSL(‘my.server’) user = ‘username’ password = ‘password’ M.login(user, password) M.search(None, ‘ALL’) for i …

Total answers: 6