2013-07-19 60 views
1

我想要一份修改該EML文件與PHP的頭信息:刪除或修改頁眉信息文件

我想刪除行消息的ID,我想更改郵件不會忽略行到。例如,刪除所有3個郵件地址,並用另一個替換它...

有人能幫助我嗎?

Received: from server.local (7.6.19.14) by mail.local 
(192.168.0.1) with Microsoft SMTP Server id 8.3.298.1; Fri, 19 Jul 2013 
08:38:42 +0200 
Received: by server.local (Postfix, from userid 1) id 62C961608B7; Fri, 19 
Jul 2013 08:38:42 +0200 (CEST) 
From: "[email protected]" <[email protected]> 
To: Recipient <[email protected]>, Recipient <[email protected]>, 
Recipient <[email protected]> 
Date: Fri, 19 Jul 2013 08:38:42 +0200 
Subject: EG... 
Thread-Topic: EG... 
Thread-Index: Ac6ESpw8LCpOq4iNTOa02MkB6MTlsQ== 
Message-ID: <[email protected]> 
Accept-Language: en-US 
X-MS-Exchange-Organization-AuthAs: Anonymous 
X-MS-Exchange-Organization-AuthSource: mail.local 
X-MS-Has-Attach: yes 
X-MS-TNEF-Correlator: 
Content-Type: multipart/mixed; 
    boundary="_002_2013074498405156741_" 
MIME-Version: 1.0 
+3

感謝您向我們展示電子郵件標題的樣子......您能向我們展示您爲完成目標所做的工作嗎? – Orangepill

+0

[file_get_contents](http://php.net/manual/de/function.file-get-contents.php)和[preg_replce](http://php.net/manual/de/function.preg-replace。 PHP)應該這樣做。請檢查它的手冊,並在需要時在[regexp](http://www.phpf1.com/tutorial/php-regular-expression.html)中查找一些教程 –

回答

0

這是一個相對簡單的preg_replace問題....這應該給你你需要的東西。

$email = preg_replace('/^Message-ID: .*\n/m','', $email); 
$email = preg_replace('/^To :(.*)\n/m', 'To: $1\n', $email); 
+0

** Frist系列效果很好,但第二個必須看起來像這樣,我認爲?** $ email = preg_replace('/^To:(。*)\ n/m','',$ email); **但是,當要-屬性具有行:** 到:收件人<[email protected]>,收件人<[email protected]>, 收件人<[email protected]> * *執行代碼時得到以下結果:** 發件人:「[email protected]」<[email protected]> 收件人<[email protected]><----該行也必須刪除 日期:2013年7月19日星期五08:38:42 +0200 –

+0

否我發現一個棘手的解決方案: $ emailx = file_get_contents(「test.eml」); $ emailx = explode(「\ n \ n」,$ emailx); $ email = $ emailx [0]; $ email = preg_replace('/^Message-ID:。* \ n/m','',$ email); $ email = preg_replace('/ ^至:(。* \ n)*日期:/ m',「至:[email protected] \ nDate:」,$ email); $ cc = $ email。「\ n \ n」。$ emailx [1]; file_put_contents(「test1.eml」,$ cc); 但是我不得不在\ n \ n之後爆炸,因爲如果字符串(整個郵件)太大,apache會崩潰......是否有更好的解決方案? –