Email
從電子郵件中提取文件附件並將其保存到文件中?
我有一封以純文字形式儲存的電子郵件(是的,標題、消息、附件,所有內容都在一個純文字文件中),我想從中提取一個 PDF 文件。我已經複製了 base64 編碼的文本,然後執行它
base64 -d
並將cat
其保存到一個文件中。然後我嘗試打開它,但沒有用,而且它看起來不像 PDF 文件。我在這裡做錯了嗎?我相當肯定它確實是用 base64 編碼的,而且它是一個 PDF 文件。
這是電子郵件:
---------- MESSAGE FOLLOWS ---------- Date: Tue, 6 Mar 2012 12:24:24 -0800 (PST) From: "Outer, Inc." <admin@outer.com> To: Mike Young <inner@outer.org> Message-ID: <169371530.01331065464959.JavaMail.admin@outer.com> Subject: Your results are in, Mike! MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_0_1998493940.1331065464916" X-Peer: 127.0.0.1 ------=_Part_0_1998493940.1331065464916 Content-Type: multipart/alternative; boundary="----=_Part_1_1254200493.1331065464936" ------=_Part_1_1254200493.1331065464936 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Great job, Mike on your baby! ------=_Part_1_1254200493.1331065464936 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <html> <body> <h3>Great job, Mike on your baby!</h3> </body> </html> ------=_Part_1_1254200493.1331065464936-- ------=_Part_0_1998493940.1331065464916 Content-Type: application/pdf; name="Baby Results.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Baby Results.pdf" JVBERi0xLjQKJeLjz9MKMyAwIG9iaiA8PC9UeXBlL1hPYmplY3QvQ29sb3JTcGFjZS9EZXZpY2VH cmF5L1N1YnR5cGUvSW1hZ2UvQml0c1BlckNvbXBvbmVudCA4L1dpZHRoIDI1My9MZW5ndGggMTYx ... HR5P9F0eg4+P8tWzo2bPl6eGcNwyLqqW+chQi7Fo/CTWPUI7Kud1ZYgpcnSg7do4SKpTy10jyggP 1dVbvqS63pYxNl1JGGcvD1P+VFdN2b7O3YBqXTuiRteun3nmUdcoObmr5qduv09
munpack 似乎是您想要的工具。