email.retr يسترد غريبة = 20 حرفا عندما يكون الجسم البريد الإلكتروني تحتوي على أحرف الصينية في ذلك

StackOverflow https://stackoverflow.com/questions/320166

سؤال

    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 والجسم، والثمانية) = popinstance.retr (thisNum) إرجاع = 20 في هيئة البريد الإلكتروني عندما يحتوي البريد الإلكتروني الحروف الصينية.

وكيف يمكنني التعامل مع هذا؟

والنص الخام من البريد الإلكتروني:

الموضوع: (B / L: 4363-0192-809.015) SI FOR 15680XXXX436

= 20

عزيزي

= 20

وSI المغلقة

وPLS ترسل لنا BL مشروع وDEBIT ملاحظة

= 20

وTKS

= 20

وMYRI

و----- الرسالة الأصلية ----- = 20

هل كانت مفيدة؟

المحلول

وربما هو شخصية الفضاء المشفرة في نقلت للطباعة

نصائح أخرى

واستخدم quopri حدة لفك السلسلة.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top