imaplib

Python: Imaplib error

隐身守侯 提交于 2019-12-12 06:17:33
问题 import serial import imaplib from time import sleep IMAP_SERVER='imap.gmail.com' IMAP_PORT=993 ser= serial.Serial ('/dev/ttyACM0',9600) while True: M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT) rc, resp = M.login('user@gmail.com', 'Password') print rc, resp M.select() for msg_num in M.search("INBOX", "UNDELETED")[1][0].split(): msg = M.fetch('1', '(BODY.PEEK[TEXT])') try: String = msg[1][0][1][139:148] except TypeError: continue print String if String == "This is just a test...": ser.write('0

Python IMAPClient/imaplib search unicode issue

﹥>﹥吖頭↗ 提交于 2019-12-12 04:35:49
问题 I'm using the IMAPClient library, but I'm getting UnicodeEncodeError when doing a search. Below is a snippet and the stack trace: imap_client = imapclient.IMAPClient('imap.gmail.com', use_uid=True, ssl=True) imap_client.oauth2_login('john@example.com', 'xxx') subject = u'Test \u0153\u2211\u00b4\u00e5\u00df\u2202' from_email = u'john@example.com' to_emails = [u'foo@example.com'] cc_emails = [] approx_date_sent = '05-Aug-2013' imap_client.select_folder(r'\Sent') search_criteria = [ u'FROM %s' %

Python 3.5 imaplib emails

做~自己de王妃 提交于 2019-12-12 04:33:26
问题 I found some code in internet regarding imaplib and configuring with my information I got it work without problem with my gmail account (but I had to change some gmail configuration to do it). I try the same code with my azure email service but I get every time the same error: > Traceback (most recent call last): File "C:\Users\Carlo\Desktop\try.py", line 66, in <module> > M = imaplib.IMAP4_SSL('mail.example.com') File "C:\Python34-32\lib\imaplib.py", line 1221, in __init__ > IMAP4.__init__

Python Tkinter Multithreading functions

和自甴很熟 提交于 2019-12-11 12:18:55
问题 I am currently working on an Email sender and recieving program with the tkinter library from python. I am using the threading module to make the program refresh the unread emails every 60 seconds while you can still continue doing stuff in the program. The threading module works when just making a print("something") command, and I can still continue doing stuff in the program. However, when I make the thread log into gmail and getting the unread email count, the whole program freezes and

Python imaplib download Gmail Text without downloading the full attachment

本秂侑毒 提交于 2019-12-11 11:24:50
问题 I am using 'imaplib' in python to fetch the email from a Gmail account. But I just want to know the content of the email, the title of the attachment, but do not need to download the full attachment. By default, myGmail = imaplib.IMAP4_SSL(...) .... (respCode, data) = myGmail.fetch(mailUid, 'RFC822') will return the whole part of email, including the whole attachment encoded as text in the return data, which is sometimes huge and unnecessary. I've searched over the internet and stackOverflow

Is there a way using Python 3 IMAPlib to retrieve both the sender address & the associated UID for a given message

女生的网名这么多〃 提交于 2019-12-11 06:20:21
问题 Using regular expressions I have managed to extract all sender addresses from the emails located in my Inbox, However I've tried and failed many times to also extract the associated UIDs for those individual emails. Here's what I have so far: result, data = mail.search(None, 'ALL') ids = data[0] id_list = ids.split() for i in id_list: typ, data = mail.fetch(i,'(RFC822)') for response_part in data: if isinstance(response_part, tuple): msg = email.message_from_bytes(response_part[1]) sender =

Is it worthwhile using IMAP COMPRESS (DEFLATE)?

拜拜、爱过 提交于 2019-12-11 01:18:31
问题 Gmail supports the IMAP COMPRESS Extension (RFC4978), specifically the DEFLATE algorithm (RFC1951) aka zlib/gzip. I'm not normally a Python programmer but I threw a quick test script together using Piers Lauder's imaplib2 to determine performance with or without compression enabled. from time import time import imaplib2, string def cb((response, cb_arg, error)): typ, data = response #print 'Message %s\n%s\n' % (cb_arg, data[0][5]) IMAP_SERVER='imap.gmail.com' IMAP_PORT=993 IMAP_USERNAME='****

Obtain partial IMAP text part

痴心易碎 提交于 2019-12-10 20:04:46
问题 I have an email interface client, and I am using IMAP for my requests. I want to be able to show, in real-time, basic email data, for a list view. As in, for example, the GMail list view. For that, I need to do an IMAP request to obtain the subject of all emails, the date of all emails, etc. This works so far. The problem is, I want to also show the first characters of the body text. If I use the BODYSTRUCTURE call to obtain the index of the text/HTML part it takes too long (for emails with

Get email subject and sender using imaplib?

拜拜、爱过 提交于 2019-12-10 11:25:56
问题 I am getting the following response after executing the code shown below the response. How can I parse through this response to get the sender (John Smith) and the subject (test)? [('13010 (BODY[HEADER.FIELDS (SUBJECT FROM)] {57}', 'From: John Smith <jsmith@gmail.com>\r\nSubject: test\r\n\r\n'), ')'] - conn.fetch(message, '(BODY[HEADER.FIELDS (SUBJECT FROM)])') 回答1: Perhaps the question/answer here will help. Try something like this: from email.parser import HeaderParser data = conn.fetch

Saving IMAP messages with Python mailbox module

旧时模样 提交于 2019-12-10 11:05:38
问题 I'm downloading messages from IMAP with imaplib into a mbox (with mailbox module): import imaplib, mailbox svr = imaplib.IMAP4_SSL('imap.gmail.com') svr.login('myname@gmail.com', 'mypaswword') resp, [countstr] = svr.select("[Gmail]/All Mail", True) mbox = mailbox.mbox('mails.mbox') for n in range(...): resp, lst1 = svr.fetch(n, 'UID') # the UID of the message resp, lst2 = svr.fetch(n, '(RFC822)') # the message itself mbox.add(lst2[0][1]) # add the downloaded message to the mbox # # how to