poplib

Trailing equal signs (=) in emails

痞子三分冷 提交于 2021-01-28 00:30:55
问题 I download messages from a Gmail account using POP3 and save them in a SQLite database for futher processing: mailbox = poplib.POP3_SSL('pop.gmail.com', '995') mailbox.user(user) mailbox.pass_(password) msgnum = mailbox.stat()[0] for i in range(msgnum): msg = '\n'.join(mailbox.retr(i+1)[1]) save_message(msg, dbmgr) mailbox.quit() However, looking in the database, all lines but the last one of the message body (payload) have trailing equal signs. Do you know why this happens? 回答1: Frederic's

Certificate Authority for imaplib and poplib python

 ̄綄美尐妖づ 提交于 2020-01-01 17:07:28
问题 I'm using imaplib and poplib to perform email collection using IMAPS and POP3S for a secure connection. But from what I've been able to determine, neither library uses a CA to confirm the validity of the certificate received. It this true? If it is, is it possible to set imaplib or poplib to use a CA? If it's not true and they do use a CA, can someone please tell me how imaplib/poplib do it? Thanks. 回答1: A quick check of imaplib.py shows that it uses ssl.wrap_socket() to implement the IMAP

Certificate Authority for imaplib and poplib python

ぃ、小莉子 提交于 2020-01-01 17:07:08
问题 I'm using imaplib and poplib to perform email collection using IMAPS and POP3S for a secure connection. But from what I've been able to determine, neither library uses a CA to confirm the validity of the certificate received. It this true? If it is, is it possible to set imaplib or poplib to use a CA? If it's not true and they do use a CA, can someone please tell me how imaplib/poplib do it? Thanks. 回答1: A quick check of imaplib.py shows that it uses ssl.wrap_socket() to implement the IMAP

error when using poplib to get email

守給你的承諾、 提交于 2019-12-13 05:23:25
问题 I am using poplib to get email from the POP3 server. But this error occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python26\lib\site-packages\myutils.py", line 251, in dxDown m=poplib.POP3('pop3.126.com') File "C:\Python26\lib\poplib.py", line 83, in __init__ self.sock = socket.create_connection((host, port), timeout) File "C:\Python26\lib\socket.py", line 500, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror:

Python: Retrieving only POP3 message text, no headers

你。 提交于 2019-12-09 12:24:03
问题 I'm trying to make a Python program that retrieves only the body text of an email without passing headers or any other parameters. I'm not sure how to go about this. The goal is to be able to send basic commands to a program via message text. What I have now is this: import poplib host = "pop.gmail.com" mail = poplib.POP3_SSL(host) print mail.getwelcome() print mail.user("user") print mail.pass_("pass") print mail.stat() print mail.list() print "" if mail.stat()[1] > 0: print "You have new

[转载]用Python处理邮件

此生再无相见时 提交于 2019-12-07 20:26:39
总体来说python处理邮件还是比较方便的,库提供了很多工具.下面我把心得写出来,给新手一个启迪,也请高手给些更好的方法. 先说接受邮件. poplib 方法. 1.poplib.POP3('这里填入你pop邮件服务器地址') 登陆服务器. 2.poplib.user('用户名 ') poplib.pass_('密码') 3.poplib.stat()方法返回一个元组:(邮件数,邮件尺寸) mailCount,size=poplib.stat() 这样mailCount就是邮件的数量,size,就是所有邮件的大小. 4.poplib.rert('邮件号码')方法返回一个元组:(状态信息,邮件,邮件尺寸) hdr,message,octet=server.retr(1) 读去第一个邮件信息. hdr的内容就是响应信息和邮件大小比如'+OK 12498 octets' message 是包含邮件所有行的列表. octet 是这个邮件的内容. 得到的message是邮件的原始内容,也就是没有解码过的,里面的内容和标题基本上都是base64编码的,下面说说如何处理原始邮件. python 的email库里提供了很多处理邮件的方法,我们先把原始邮件转成email实例,这样就可以用库方法处理邮件. email.message_from_string()

python利用poplib来收取邮件

与世无争的帅哥 提交于 2019-12-06 02:25:15
收取邮件有两种方式,一种是POP3, 另一种是IMAP,它们都是收取邮件服务器支持的协议,我们用foxmail进行邮件的收发,感觉不到收发的流程,而实际上收和发是作用在不同的服务器上,发邮件有专门的发邮件服务器,收邮件也有专门的收邮件服务器,发邮件只负责发送不管收取,同时收取邮件也不管如何发邮件,因此在测试时收和发邮件是分开进行的,虽然大多数时候收发邮件服务是装在一个服务器上,但测试测的是协议,如SMTP, 如POP3, IMAP,python中的poplib收取邮件还是非常简单的,重点是收来的邮件需要解析,因为SMTP是进行编码过的,收来的邮件需要进行处理后才能被我们阅读,因此又要用到email模块,SMTP用email来传递内容,POP3用email来解析内容 poplib #返回所有邮件的编号 list(self,which=None): ['response',['message_count, octets'],octets]/[scan listing for the message] ----------------------------- ('+OK 7 messages:', ['1 1080', '2 1080', '3 1079', '4 675265', '5 675506', '6 675534', '7 597'], 61) #收取整封邮件

Python: Retrieving only POP3 message text, no headers

好久不见. 提交于 2019-12-03 14:34:58
I'm trying to make a Python program that retrieves only the body text of an email without passing headers or any other parameters. I'm not sure how to go about this. The goal is to be able to send basic commands to a program via message text. What I have now is this: import poplib host = "pop.gmail.com" mail = poplib.POP3_SSL(host) print mail.getwelcome() print mail.user("user") print mail.pass_("pass") print mail.stat() print mail.list() print "" if mail.stat()[1] > 0: print "You have new mail." else: print "No new mail." print "" numMessages = len(mail.list()[1]) for i in range(numMessages):

Get emails with Python and poplib

∥☆過路亽.° 提交于 2019-11-30 03:58:35
I would like to log into my account with Python and get python to print the messages I received in my mailbox. I know how to connect import getpass, poplib user = 'my_user_name' Mailbox = poplib.POP3_SSL('pop.googlemail.com', '995') Mailbox.user(user) Mailbox.pass_('my_password') I don't know how to get Python to display my messages. I tried all the functions in the poplib doc. They only display numbers. You have not posted your source code, but here is my response: How to get the total number of messages: (numMsgs, totalSize) = self.conn_pop3.stat() How to get a specific message, knowing its

Get emails with Python and poplib

喜夏-厌秋 提交于 2019-11-29 01:03:36
问题 I would like to log into my account with Python and get python to print the messages I received in my mailbox. I know how to connect import getpass, poplib user = 'my_user_name' Mailbox = poplib.POP3_SSL('pop.googlemail.com', '995') Mailbox.user(user) Mailbox.pass_('my_password') I don't know how to get Python to display my messages. I tried all the functions in the poplib doc. They only display numbers. 回答1: You have not posted your source code, but here is my response: How to get the total