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.

imaplib
Filter by
Sorted by
Tagged with
1 vote
2 answers
881 views

Is msg.is_attachment() enough to get all the attachments from email in python, or should we check that msg.is_multipart() too?

I am searching for mails from a particular sender with a particular subject. I take the first email, and then want to retrieve the attachments from it. I'm using imaplib. My code - _, mails = ...
Sneha Tunga's user avatar
2 votes
0 answers
175 views

Search mails with french accent in gmail with python imaplib [duplicate]

Imaplib search function throws an exception "SEARCH command error: BAD [b'Could not parse command']" as soon as I use a character with a french accent, like é, è or à. Here is my code: ...
Nono's user avatar
  • 21
-1 votes
1 answer
2k views

How to search for email where the subject contains numbers

I'm looking for emails where the title has information on how many Bitcoin I received, but as there's a number in the email title, I want a way to find emails where the number is equal to or greater ...
Dkns's user avatar
  • 75
0 votes
1 answer
805 views

Parse multipart/related emails

I'm trying to parse emails and convert tables within them into pandas dataframes. Since some of the emails are multipart, I took some code from this answer. The following code works fine but it breaks ...
younggotti's user avatar
0 votes
0 answers
267 views

Socket error: EOF when using ImapLibrary2 with Robot Framework

I'm trying to use ImapLibrary2 for RobotFramework to connect to imap.gmail.com, find a confirmation email and then open the link to validate the account. Open Mailbox host=imap.gmail.com username=...
Lorenzo 's user avatar
0 votes
0 answers
217 views

python imaplib mail.search is it possible to have a lot of threads each searching for different email?

I am wokring on a script that utilizes multiple threads, each searching for a different email. The issue is, that I cant use more then +- 20 threads at the same time. I tried two different approaches. ...
Konik's user avatar
  • 33
0 votes
1 answer
963 views

IMAP command UID FETCH: Too long argument

I'm using imaplib (imap4) with Python 3.7.0 and I'm trying to fetch a large folder and I'm getting FETCH command error: BAD [b'Error in IMAP command UID FETCH: Too long argument (0.001 + 0.122 + 0.122 ...
TehPirate's user avatar
  • 154
1 vote
0 answers
257 views

Imaplib ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

The following is the code I am using to create an interactive Tkinter Email Checker, and just overall Tkinter-based GUI for all sorts of different things I may need it such as calculators for ...
FritzPappo's user avatar
0 votes
0 answers
159 views

Unable to search message with message-ID, BAD [b'Could not parse command']

Good day everyone, I'm working on a personal python small project here, trying to search messages with messages-id, but encounter error as below : imaplib.error: SEARCH command error: BAD [b'Could not ...
HumbleFox's user avatar
2 votes
0 answers
1k views

Python http connection problems

Hi so I wrote the following code that's totally running fine, until sometimes it just decides to throw this error. That's what's really tripping me out, the fact that it works fine for the most part ...
Simeon Gellert's user avatar
0 votes
1 answer
144 views

imaplib - Moving mails to a folder fails without an error log

My python code selects some mails and move them to another folder. # A.py def __init__(self): account = conf.account password = conf.password server = conf.imap_server ...
yoon's user avatar
  • 1,255
0 votes
1 answer
79 views

MailMessage.login_imap(self, connection, user, password) AssertionError: error not raised

I am trying to test my method login_imap() but got AssertionError: error not raised. Python 3.9 What do I do wrong? def login_imap(self, connection, user, password): try: if ...
Robert's user avatar
  • 1
0 votes
1 answer
78 views

Is there a way to send emails in python without Windows asking you "How you want to open this file"?

I am designing a way to have an online game without having to pay for a server. To do this I use the following libraries: import imaplib, smtplib, ssl import email from email.header import ...
Simon Champney's user avatar
0 votes
1 answer
83 views

No national characters in mail subject using imaplib, email in Python to read gmail inbox

Windows. Python 3.9. As a value of mail subject I get other characters instead of Polish characters - I get: Odpowied�� automatyczna: "Re: Program licz��cy ceny i sprzeda�� w allegro dla EAN��w&...
Jakub Zbudniewek's user avatar
0 votes
0 answers
386 views

Accessing a shared mail box through imaplib4 which has no password

I'd want to gain access to a Generic Mail Box (Shared Mail Box) and retrieve the attachments from an unread email. The problem is that the mail box does not have a password, however imap.login(user, ...
Annabelle79's user avatar
1 vote
0 answers
521 views

Why won't this imap.select("INBOX") work as expected for this google mail account?

I am working on an app that must log into an email account to process some emails. In this case the email account is being run through the google business suite (so it's not a gmail domain). The app ...
levraininjaneer's user avatar
1 vote
1 answer
1k views

Line breaks in IMAP - =\r\n - how to decode?

I am trying to make an email scraper that scrapes through certain emails looking for values to store them in a CSV file. I have been trying a lot of things to get this problem solved but without ...
BartMolk's user avatar
1 vote
1 answer
299 views

Python3, imaplib, expunge command used as per message in a loop over all messages in folder

I have a bunch of functions to store all attachments from all mails in one imap folder. Attachments are json datasets for further processing. To avoid oubliettes after connection loss and re-...
elektrokid's user avatar
1 vote
0 answers
233 views

How do I decode strings-like objects to extract subject?

I am trying to fetch emails so that I can save them in a spreadsheet. So far, it works without getting the status of the message, but when I try to fetch the status ('Delivered', for example) I get ...
alb's user avatar
  • 185
1 vote
1 answer
361 views

Why does Python imaplib return Errno 111: Connection refused when I try to instantiate the IMAP4() object in GitPod?

I am trying to use the Python imaplib library in GitPod. Following the documentation, I imported imaplib and instantiated the IMAP4 object with the following line of code: M = imaplib.IMAP4() This ...
Julius Hamilton's user avatar
0 votes
0 answers
89 views

IMAPLIB XML attachments not detected

The following code doesn't consider there is an attachment if the attachment is with the extension .XLS but in XML format. I am using IMAPLIB and everything works fine except when the attachment is an ...
Ludogiraud's user avatar
0 votes
1 answer
2k views

IMAPlib how to select only emails since a given date

With IMAPlib I am using: self.m.select("Inbox") typ, mail = self.m.search(None, "(ALL)", f'(SENTSINCE {datesince})') where: datesince = (datetime.date.today() - datetime....
Ludogiraud's user avatar
0 votes
1 answer
436 views

python IMAPlib how to move emails with no UIDs into sub folders

I am using the following to move emails into subfolders, however this crashes in some cases because I am told some emails don't have UIDs. Is there an alternative to this to move emails into ...
Ludogiraud's user avatar
1 vote
1 answer
473 views

imaplib.py: 'NoneType' object has no attribute 'replace'

I've set up a workflow on GitHub and when I run it, I'm getting the following error: 1 Run python app.py 2 python app.py 3 shell: /usr/bin/bash -e {0} 4 env: 5 pythonLocation: /...
ARNON's user avatar
  • 1,157
1 vote
1 answer
293 views

Stripping out the junk from imaplib.list() results

Here is my code: import imaplib with imaplib.IMAP4_SSL("[email protected]", port=993, timeout=20) as imap: imap.login('user', 'pwd') status, folders = imap.list() This is what I get ...
NO3NO's user avatar
  • 11
0 votes
1 answer
927 views

Why am I getting [Errno 11001] getaddrinfo failed when retrieving from config?

I'm using ConfigParser to pull IMAP details for email login which works fine on Linux, however I keep getting socket.gaierror: [Errno 11001] getaddrinfo failed when running on Windows. I'm using ...
TehPirate's user avatar
  • 154
1 vote
1 answer
824 views

How to select email from a particular sender? (IMAPLIB) [duplicate]

I want to select emails from a particular sender,[email protected] in Inbox gmail = imaplib.IMAP4_SSL("imap.gmail.com", 993) gmail.login(gmail_username,gmail_password) gmail.select('Inbox', ...
Atom Store's user avatar
0 votes
2 answers
1k views

How to read HTML email - Python

I would like to read emails from IMAP mailbox and extract "From", "Subject" and "Body" (which is HTML) every time new email comes in, it should make the unread email read ...
Robba's user avatar
  • 37
0 votes
1 answer
32 views

imaplib reading incorrect email

I'm trying to have my program search for a specific item then read the email. However, when I try to print its subject, it instead gives the subject of a completetly different email, even though I ...
doctor_senpai69's user avatar
1 vote
1 answer
3k views

imaplib.error: SEARCH command error: BAD [b'Could not parse command']

Code: Been getting the error in title but I don't see issue here def test(): imap_host = 'imap.gmail.com' imap_user = 'email' imap_pass = 'pass' imap = imaplib.IMAP4_SSL(imap_host)...
Bobby Boffer's user avatar
0 votes
0 answers
304 views

Polling my E-Mail for new Messages with Python

I have a problem with my Python code. The code shall read from a E-Mail Inbox (hostet by Strato) and react to new E-Mails. The background is using it as a alarm monitor for the volunteer firefighter ...
Christoph Renner's user avatar
0 votes
2 answers
1k views

How to mark an email as seen after reading it with 'mark_seen = False' in imap_tools python?

So first of all this is my code: with MailBox('imap.gmail.com').login('username', 'password', 'INBOX') as mailbox: for msg in mailbox.fetch(AND(mark_seen=False, from_="some_domain&...
the_guy71639's user avatar
0 votes
1 answer
143 views

html seperates after each equal sign

Currently iam trying to get a full link out of an email using imaplib & email. My current code looks like this: result, data = mail.uid('search', None, 'HEADER Subject "Confirm your ...
DerApfel0's user avatar
0 votes
0 answers
408 views

How does imap SEARCH work on Microsoft Exchange with python imaplib?

My goal is to get a list of e-mails received since a certain date from a Microsoft exchange sever using imaplib in python. So far I've found out that Exchange does not support the sort command. But ...
spades's user avatar
  • 9
0 votes
0 answers
192 views

IMAPLIB - timeout eror

I download Email attachments with Python once per week. It was working for more than one year without any problems. But since one week, I get a TimeoutError: [Errno 60] Operation timed out I didn't ...
Florian Seliger's user avatar
0 votes
2 answers
678 views

How to setup connection to local hmail server in python?

I've set up a hmailserver on my local machine. I'm also using a python script that reads emails. The python script runs fine when I connect to outlook. but I have a problem with the local connection ...
yehyafarhat's user avatar
0 votes
1 answer
110 views

Newly created folder with imaplib is hidden. How can I unhide it?

I am using strCreateYN, strCreateResponse = mail.create('INBOX.Foldername') to create a folder. The folder gets created and I can move messages to it. For some reason, the folder is hidden, and I ...
Andy Delgado's user avatar
0 votes
0 answers
216 views

Python decoding message object of email but got 3 "From" headers

Problem I'm trying to print email metadata using python imap.lib. The message object I got from imap4.fectch is supposed to contain proper header information, but one specific email returns 3 "...
Ian's user avatar
  • 1
0 votes
0 answers
223 views

Python searching email using imap.lib

Problem: I'm trying to filter emails by date using imap4.search(charset, criterion[]) function, but it won't work. What I've tried: Naturally I started printing data returned from typ, data = M.search(...
Ian's user avatar
  • 1
1 vote
1 answer
527 views

"TypeError: can't concat int to bytes" imaplib error

I am creating something so when it receives an email depending on what is the subject line it does a function now the code I have works in python 2.7 and runs in 3.7 but gives one error "...
Daniel Caminero's user avatar
1 vote
2 answers
250 views

I want to mark the gmail messages Seen by imaplib

I want to parse some gmail emails by python. I want when the message is read to put it seen. I put this code but it is not marked as seen? #read or seen email mail.store(i,'+FLAGS', '\\Seen') Do you ...
Fanny Zhingre's user avatar
0 votes
2 answers
294 views

How to move ONLY messages that have attachments?

I have the following code moving all emails in a folder to the "Old" folder using Mailbox package: with MailBox('mail.yu.nl').login('[email protected]', 'yu', initial_folder='INBOX') as mailbox:...
Max's user avatar
  • 469
2 votes
1 answer
2k views

How to extract the body of an multipart email and save the attachments using python IMAP?

I am working on a project where I get emails with a specific 'subject'. There are forwarded to me by users. The body consists of text but in the original email and no new text is entered above the ...
Aishwarya Prabhu's user avatar
1 vote
2 answers
2k views

Trying to login to my gmail; imaplib.error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'

I'm new to Python, and I'm doing this for work, so please explain like im 5 years old I'm trying to login to my gmail account to automatically download all attachments. I'm trying to initialize a ...
ye ye's user avatar
  • 21
0 votes
0 answers
353 views

Python imaplib documentation

I'm looking into the python imaplib library and starting testing things. I looked in the documentation and read that get_payload() is deprecated and you have to use get_body(). When I look at my ...
Deus's user avatar
  • 39
0 votes
1 answer
1k views

imaplib , imap_tools return an error after a few minutes. (imaplib.abort: command: SELECT => IMAP4rev1 Server logging out)

I use this code to get unseen and new messages from my yahoo mail and find the messages with a specific URL. from imap_tools import MailBox, AND import re from config import email, password from ...
M MO's user avatar
  • 322
0 votes
2 answers
937 views

read email response from outlook using email lib python

Hello currently I am using IMAPLIB and EMAIL library of python for reading and get then content sends of different emails, but when I received an email response from outlook, I can not get the content ...
Steven Ramirez's user avatar
0 votes
0 answers
248 views

imaplib.IMAP4.error set a failure message when connecting (Python)

I'm having trouble defining a message in the Gmail login code when the credentials are wrong. def connect(): imap_host = 'imap.gmail.com' email = '[email protected]' password = input("...
Guilherme's user avatar
1 vote
2 answers
4k views

How to get unseen emails using python imap-tools

from imap_tools import MailBox, AND import re yahooSmtpServer = "imap.mail.yahoo.com" client = MailBox(yahooSmtpServer).login('myEmail', 'myPassword', 'INBOX') for msg in client.fetch(AND(...
M MO's user avatar
  • 322
1 vote
0 answers
412 views

yahoo mail error 550, b'Request failed; Mailbox unavailable'

So this code works for gmail, when i tried it on yahoo mail i get this error, (550, b'Request failed; Mailbox unavailable') mail = imaplib.IMAP4_SSL(imap_server) mail.login(emaill, pwd) # select ...
user15317824's user avatar

1 2
3
4 5
14