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

How to save file for every content_type rather than every uid with imaplib and email

I am successfully saving the content for each email with the following code, as a .txt, .html or .PDF file. However, I would like to save a version of every content_type, for each email (for each uid). Currently it is only saving one file type for…
tedioustortoise
  • 259
  • 3
  • 20
0
votes
1 answer

Python reading email from outlook account using imaplib/imapclient vs exchangelib?

I am setting up a script to read incoming emails from an outlook.com account and I've tested a few approaches with imaplib and was unsuccessful. Yet when I tried with Exchangelib I was able to do this. I'm not entirely sure why Exchangelib works and…
alex
  • 1,905
  • 26
  • 51
0
votes
1 answer

How to do a general email search in python

in imaplib, mail.search requires a criterion, see documentation https://docs.python.org/2/library/imaplib.html and the criterion options https://gist.github.com/martinrusev/6121028 However, I need to be able to use a more generalized search. A set…
AlbinoRhino
  • 467
  • 6
  • 23
0
votes
0 answers

Imaplib search returns wrong UIDs after moving some mails to trash

I am trying to get all the UID's of the INBOX folder in a gmail account using imaplib (account is new for testing purposes). It worked fine at first (i.e. when I had only sent mails to the account), but after moving some mails to trash, my code now…
Zsigma
  • 1
0
votes
0 answers

Is imaplib safe to use for syncing Outlook office 365 emails?

All, just wanted to understand if Python imaplib is safe to use while working with emails. Im hard coding the email address and password in the script so just wanted to make sure it is OK to do that. If yes, how does it help to protect the security…
Wendy
  • 123
  • 3
0
votes
1 answer

Using email python library to get attachment name doesn't work

here's what my message details looks like: I used the following python code to get attached file name from this mail: import email mail = email.message_from_string(bytes.decode(email_body)) if mail.get_content_maintype() != 'multipart': …
Kuldeep
  • 23
  • 2
  • 8
0
votes
1 answer

How to read specific email in python

I have the following code: import imaplib import email imap = imaplib.IMAP4_SSL('imap.naver.com') id = 'abc@naver.com' pw = '123' imap.login(id, pw) imap.select('inbox') status, data = imap.uid('search', None, '(HEADER FROM…
tohardtme
  • 101
  • 4
0
votes
1 answer

Format subject email

I want to recover the value "SUBJECT" of an email import imaplib import os import email email_user = 'xxxxxxx@xxxxxxx' email_pass = 'xxxxxxxx' M = imaplib.IMAP4_SSL('imap.gmail.com', 993) M.login(email_user, email_pass) M.select('INBOX') typ,…
Badze
  • 3
  • 1
0
votes
1 answer

Why imaplib.fetch RFC822 response has such strange format

When I fetch data using imaplib rv, data = imap.fetch("1", '(RFC822)') I get response of the following shape [(b'1 (RFC822 {35661}', b'Delivered-To: ... here goes the message' ), b')'] What is the rationale here? Why opening (b'1 (RFC822…
0
votes
1 answer

What input is imaplib's Internaldate2tuple expecting?

The API reference for Python 3 says imaplib's Internaldate2tuple parses an IMAP4 INTERNALDATE string, yet I can't find the information anywhere what that exactly means. The reverse function (Time2Internaldate) seems to produce one of these…
Villahousut
  • 115
  • 1
  • 11
0
votes
0 answers

Node module 'imap' is returning 401 after sometime while performing any operation

In our project, we are using 'imap' node module to connect to ms office outlook mail server and also we are doing many operations like fetch, getBoxes, search, setFlags etc using imap module. Our server is trying to perform the above actions on mail…
Mrunal
  • 1
0
votes
0 answers

parsing data from imaplib emails

So I found a this script in another thread. Everything works fine except I cannot get the message "From:", "Date:", and the "Subject:" to show. They show up as NONE. Below is the code import imaplib from email.parser import HeaderParser myHost =…
BigEfromDaBX
  • 157
  • 1
  • 2
  • 10
0
votes
0 answers

Connection to the exchange server fails with some invalid error while fetching the password

I have got the POP server and the IMAP server details for my exchange server. And i am able to connect to both using poplib.POP3_SSL(host,port) or imaplib.IMAP4_SSL(host,port). After that in case of imaplib when i use login method it throws an…
Tusharg
  • 1
  • 1
0
votes
1 answer

Get only the text/plain section of an email obtained with imaplib in Python

I'm trying to get only the text/plain section of an email i received with imaplib in Python: #!/usr/bin/env python import imaplib import sys from pprint import pprint from email.parser import HeaderParser from email.header import…
rebutia
  • 15
  • 3
0
votes
1 answer

TypeError: can't concat int to bytes

Running this code in order to read email message: if uid > uid_max: result, data = server.uid('fetch', uid, '(RFC822)') # fetch entire message msg = email.message_from_string(data[0][1]) I'm getting this error: TypeError:…