2013-07-07 78 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); 
?> 
相關問題