ModuleNotFoundError:没有名为'rfc822'的模块

问题描述 投票:0回答:1

[我试图阅读我的电子邮件python版本3.6.9和pip3版本9.0.1。当我运行以下脚本时,它返回下面显示的错误。我尝试使用pip和pip3安装rfc822。您能帮我解决这个问题。

非常感谢Erik

ERROR

    Traceback (most recent call last):
  File "/home/webapp/git/RA Functions/test.py", line 3, in <module>
    import rfc822
ModuleNotFoundError: No module named 'rfc822'

CODE

import poplib
import string, random
import rfc822
from io import StringIO

def readMail(): 
    SERVER = "pop.gmail.com"
    USER = "[email protected]"
    PASSWORD = "mypassword"

    # connect to server
    server = poplib.POP3(SERVER)

    # login
    server.user(USER)
    server.pass_(PASSWORD)

    # list items on server
    resp, items, octets = server.list()

    for i in range(0,10):
        id, size = string.split(items[i])
        resp, text, octets = server.retr(id)

        text = string.join(text, "\n")
        file = StringIO.StringIO(text)

        message = rfc822.Message(file)

        for k, v in message.items():
            print(k, "=", v)

readMail()
python-3.x rfc822
1个回答
0
投票

此模块为不推荐使用,因为版本2.3以上:应优先使用email程序包而不是rfc822模块。提供此模块仅是为了保持向后兼容性,已在Python 3中删除。

有关更多信息,请访问:Deprecated Link

但是这里是另一个模块,它是plone.rfc822

此包提供了用于将zope.schema字段描述的内容对象转换为RFC(2)822样式消息的原语。它利用了Python标准库的电子邮件模块。

用于安装:pip install plone.rfc822

有关信息,请访问:Active Link

© www.soinside.com 2019 - 2024. All rights reserved.