我正在写一个能够通过IMAP在Python中备份和恢复Gmail中的电子邮件的工具。 在某些情况下,从Gmail备份的电子邮件包含奇怪的字符:^ @然后无法由Gmail IMAP重新导入。IMAP服务器无法接收的电子邮件中的奇怪字符
Delivered-To: [email protected]
Received: by 1x.xx.xx.xx with SMTP id jjjjjjjj;
Tue, 14 Jun 2011 16:56:26 -0700 (PDT)
Received: by x.x.x.x with SMTP id xxxx.xxx;
Tue, 14 Jun 2011 16:56:16 -0700 (PDT)
Return-Path: <[email protected]>
Delivery-Date: Mon, 23 Aug 2010 17:58:56 +0200
Received: from xxxxx (xxxxx [x.x.x.x])
by xxxx (node=xxx) with ESMTP (xxx)
id xxx ; Mon, 23 Aug 2010 17:58:56 +0200
Received: from [x] (x)
by x (x) with x (x)
id x; Mon, 23 Aug 2010 17:58:50 +0200
Message-ID: <[email protected]>
Date: Mon, 23 Aug 2010 17:58:48 +0200
From: Foo Bar <[email protected]>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2
MIME-Version: 1.0
To: [email protected] <x>
Subject: The subject
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
X-Provags-ID: xxxxxxxxxxx=
Envelope-To: [email protected]
Hello All,
blah blah blah
^@
最后他们是这个特殊字符。有时会出现在中间的其他电子邮件中。 当我将电子邮件存储到磁盘(eml格式)时,我只需保存并恢复它即可。
编码看起来是正确的。
这个角色是什么? 当我将电子邮件存储在eml中时,我是否做错了什么?
一些指导将不胜感激。
谢谢。
'^ @'是一个空字符。不知道它如何到达那里。你能粘贴你的代码吗?参考:http://www.robelle.com/smugbook/ascii.html – ZnArK
电子邮件是8位,“内容传输编码:8位”。并非所有系统/软件都能处理8位邮件。正如@ZnArK所说,'^ @'是NULL的常见表示。 – MattH
我认为它是在电子邮件最初创建时插入的。然后,Gmail Imap不想接受它。我有一个问题,但。有IMAP通信和SSL。你认为SSL层可以添加它吗?代码非常简单,我通过python imaplib获取电子邮件并将其保存在文件中。该文件以'wb'打开。如果您有任何想法,请告知我。谢谢 – zoobert