2013-07-07 75 views
0

我正在清理电子邮件之前,他们被存储在数据库中。 fandango电子邮件被发送为编码为4(引用 - 可打印)。这里是不解码消息的一部分...PHP quoted_printable_decode不工作在Fandango纯文本/文本电子邮件

= 0A 0A = = A0 = 0AJohn = 0A(800)123-4567 = 0A 0A = -----转发邮件=

= 20 = 0ASent = 20周四= 20日= 204 = 202013 = 204:14 = 20PM = 0ASubject = 20Your = 20Despicab =

le = 20Me = 202 = 20iTunes = 20Download = 0A = 20 = 0A = 0A = 0ADespicable = 20Me = 202 = 20 = 0A = 20 = 20 = 0A = 20Your = 20purchase = 20 =

= 20tickets = 20for = 20Despicable = 20Me = 202 = 20has = 20earned = 20you = 20A = 20complimentary = 20download = 20of = 20t =

他= 20song = 20'Just = 20A = 20Cloud = 20Away'= 20by = 20Pharrell = 20from =第二十条= 20Original = 20Motion = 20Picture = 20So =

undtrack = 20on = 20iTunes。= 20 = 0AWe = 20hope = 20you = 20enjoy = 20the = 20song = 20and = 20the = 20film!= 0AIf = 20you = 20ha =

ve = 20iTunes = 20installed,= 20click = 20here = 20to = 20start = 20your = 20complaimer = 20download。= 0AIF = 20 =

YOU = 20DO = 20NOT = 20HAVE = 20iTunes = 20INSTALLED:= 0A = 0A1 = 20Download = 20iTunes = 20for = 20Mac = 20or = 20Window =

S,= 20free = 20of = 20charge = 20AT = 20www.iTunes.com = 20 = 0A2。= 20Open = 20iTunes = 20于是= 20click = 20iTunes = 20Sto =

重。= 20 = 0A3。= 20Click = 20Redeem = 20under = 20Quick = 20个站点。= 20 = 0A4。= 20Enter =第二十条= 20code = 20below = 20Your = 20 =

下载= 20will = 20start = 20immediately = 20Enjoy = 20 = 0ADownload = 20Code:。= 20FML6H34XXTMJ = 20 = 0AC =

但是当我使用quoted_printable_decode()在变量上它不会产生文本。


此URL的作品,尽管在ASP/VB解码器...

http://www.motobit.com/util/quoted-printable-decoder.asp

我猜这里的代码是有关...

http://www.motobit.com/tips/detpg_quoted-printable-decode/

它正确地解码了报价可打印的HTML。希望这会帮助有人试图帮助我。我相信我不是唯一一个遇到可打印的报价电子邮件的人。

回答

0

它看起来像您张贴的quoted-printable编码的字符串中有一些空格。这可能是导致问题的原因 - 如果它是真正引用的 - 可打印的,那么编码后的字符串不应包含任何空格。可打印的空格= 20。如果您使用替换功能(例如PHP的str_replace)用= 20替换编码字符串中的空格,那么您将得到以下可引用打印的编码字符串:

John = 0D = 0A(800)= 20123-4567 = 0D = 0A = 0D = 0A ----- = 20Forwarded = 20Message = 20

然后,可以使用PHP的quoted_printable_decode()函数对此字符串进行解码。

+0

嗯,这似乎是我的移动方向是正确的。你还看到其他什么吗?我用电子邮件的大部分内容更新了我的问题。我想过只是手动转换它,我不想在这个问题上浪费三天的时间。让我知道,谢谢! – John

0

如果将上面引用的可打印编码文本复制到文件中,则运行以下PHP脚本(该脚本从文件读取带引号的可打印文本,使用str_replace函数删除空格,然后解码引用的使用quoted_printable_decode功能)-printable文本,你应该看到它产生正确的解码输出:

<? 
$filename="./qp.txt"; 
$file = fopen($filename,"r"); 
$qp = fread($file,filesize($filename)); 
fclose($file); 

$qp=str_replace(" ", "", $qp); 
print "<plaintext>";  
print quoted_printable_decode($qp); 
?> 
相关问题