Questions tagged [imaplib]

Python module to provide an Internet Message Access Protocol (IMAP) client implementation. This protocol lets you access mail folders stored on a central mail server, as if they were local.

Python module to provide an Internet Message Access Protocol (IMAP) client implementation. This protocol lets you access mail folders stored on a central mail server, as if they were local.

694 questions
0
votes
1 answer

Finding emails by subject name with Python 3

I'm trying to pull emails in my inbox with a certain subject name by using the following code: import imapclient import pprint imapObj =…
0
votes
1 answer

Parsing dates with multiple formats

The dates returned by imaplib are in the following format: dates = [ 'Mon, 27 May 2019 13:13:02 -0300 (ART)', 'Tue, 28 May 2019 00:28:31 +0800 (CST)', 'Mon, 27 May 2019 18:32:13 +0200', 'Mon, 27 May 2019 18:43:13 +0200', 'Mon, 27 May…
AK91
  • 671
  • 2
  • 13
  • 35
0
votes
1 answer

Gmail - LOGIN Invalid credentials error no two factor authentication

I´m trying to connect my python-scrip with Gmail. No two factor authentication... (i checked manually) SMTP_SERVER = "imap.gmail.com" mail = imaplib.IMAP4_SSL(SMTP_SERVER) mail.login(emailAddress,password) And after login i got this…
Dana Yeger
  • 617
  • 3
  • 9
  • 26
0
votes
0 answers

Why does using Message.get_payload() give the correct string, while using Message.get_payload(decode=True) gives an incorrect string?

My code connects to an email inbox, and reads subjects and contents of each email. My code: def decode_email(self, raw_email): msg=email.message_from_string(raw_email.decode('utf-8')) content = '' if msg.is_multipart(): for…
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
2 answers

Python imaplib - get_filename() not working when attachment has UTF-8 characters

I have this function that downloads all attachments from a given email using imaplib # Download all attachment files for a given email def downloaAttachmentsInEmail(m, emailid, outputdir, markRead): resp, data = m.uid("FETCH", emailid,…
J. C.
  • 109
  • 2
  • 11
0
votes
0 answers

Get only latest email attachment from same subject in Python using imaplib

I want to automatically download the latest email attachment from gmail based on subject. i have daily data with same subject in email, and i want automatically download it everyday, can u guys help complete my code? Here's my code : typ, msgs =…
0
votes
0 answers

How to get email message in outlook account using IMAP?

I tried one sample program for getting an email message in outlook account using IMAP. In this account, I have 20 folders its getting all email messages except these folders (contact, calendar, task) not getting data its throwing server error. How…
hari prasanth
  • 716
  • 1
  • 15
  • 35
0
votes
1 answer

Why are these two IMAP Search results different from one another?

I'm using imaplib, and trying to fetch emails with a certain subject header value. My code: res, tmp = self.mail.uid('search', None, 'HEADER Subject "SUBJECT_HERE"') print(tmp) print(res) print("test 2 goes:") rr, tt =…
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
0 answers

Fetch X-GM-THRID X-GM-MSGID for all unseen messages using python

when i try to fetch X-GM-THRID and X-GM-MSGID for each mail using uid via for loop it fetch only 1st unseen mail X-GM-THRID and X-GM-MSGID rest are none. why and how to fetch the X-GM-THRID and X-GM-MSGID of all unseen mail one by one.…
0
votes
0 answers

Why searching emails with Date HEADER doesn't work?

I'm trying to get certain emails with HEADER values. When I try with a Subject HEADER, it works properly. res, tmp = self.mail.uid('search', None, 'HEADER Subject "Some Subject"') But when I try with a Date HEADER, it returns an empty list. …
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
1 answer

How can I search a mailbox with the last checked time, not a date?

My python code imports imaplib, and goes like: mail = imaplib.IMAP4_SSL(host=server, port=port) mail.login(account, password) mail.select() typ, msgnums = self.mail.search(*WHERE I WANT TO IMPLEMENT*) I connect to the server and check the inbox…
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
1 answer

Using Ubuntu 20.4 & Python Imaplib: Can I override ssl.SSLError: [SSL: DH_KEY_TOO_SMALL]?

since updating to Ubuntu 20.4 from 18.4 I can no longer access one of my email addresses import imaplib imap = imaplib.IMAP4_SSL('') aborts with the error message ssl.SSLError: [SSL: DH_KEY_TOO_SMALL] dh key too small…
576i
  • 7,579
  • 12
  • 55
  • 92
0
votes
1 answer

How can I decode email contents that are differently "Content-Transfer-Encoding" encoded?

I'm reading emails with imaplib, and found out that some email contents are encoded base64, and some 7bits. I tried to decode it with 'Content-Transfer-Encoding' value. But even more, some have 'Content-Transfer-Encoding' header in message…
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
1 answer

Why are the same contents decoded differently according to mail clients?

My code checks a mailbox, and forwards every mail to another user. But I found out that the same contents are decoded differently according to mail clients(I mean, when sent with account@gmail.com, with account@naver.com, and etc). For…
yoon
  • 1,177
  • 2
  • 15
  • 28
0
votes
1 answer

imaplib not working with some outlook365 accounts

I am trying to connect to an email account with the imaplib python module but it doesn't work. With @outlook it works fine for me, but with @mydomain it doesn't work. It's not a credential issue because I tried a POP connection and it worked, but…
Danilo Toro
  • 569
  • 2
  • 15