【问题标题】:email.retr retrieves strange =20 characters when the email body has chinese characters in it当电子邮件正文中包含中文字符时,email.retr 会检索奇怪的 =20 个字符
【发布时间】:2010-09-24 03:00:54
【问题描述】:
    self.logger.info(msg)
    popinstance=poplib.POP3(self.account[0])
    self.logger.info(popinstance.getwelcome())
    popinstance.user(self.account[1])
    popinstance.pass_(self.account[2])
    try:
        (numMsgs, totalSize)=popinstance.stat()
        self.logger.info("POP contains " + str(numMsgs) + " emails")
        for thisNum in xrange(1, numMsgs + 1):
            try:
                (server_msg, body, octets)=popinstance.retr(thisNum)
            except:
                self.logger.error("Could not download email")
                raise
            text="\n".join(body)
            mesg=StringIO.StringIO(text)
            msg=rfc822.Message(mesg)
            MessageID=email.Utils.parseaddr(msg["Message-ID"])[1]
            self.logger.info("downloading email " + MessageID)
            emailpath=os.path.join(self._emailpath + self._inboxfolder + "\\" + self._sanitize_string(MessageID  + ".eml"))
            emailpath=self._replace_whitespace(emailpath)
            try:
                self._dual_dump(text,emailpath)
            except:
                pass
            self.logger.info(popinstance.dele(thisNum))
    finally:
        self.logger.info(popinstance.quit())

(server_msg, body, octets)=popinstance.retr(thisNum) 当邮件中包含中文字符时,邮件正文中返回=20。

我该如何处理?

电子邮件的原始文本:

主题:(B/L:4363-0192-809.015) SI FOR 15680XXXX436

=20

亲爱的

=20

SI 封闭

请将提单草稿和借记单寄给我们

=20

TKS

=20

MYRI

----- 原始消息 -----=20

【问题讨论】:

    标签: python email fonts jython asianfonts


    【解决方案1】:

    可能是quoted-printable中编码的空格字符

    【讨论】:

      【解决方案2】:

      使用quopri 模块解码字符串。

      【讨论】:

        猜你喜欢
        • 2019-07-28
        • 2011-12-26
        • 2011-02-27
        • 2020-01-12
        • 2018-03-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-25
        相关资源
        最近更新 更多