删除或修改EML文件中的标题信息

时间:2013-07-19 07:44:30

标签: php

我想用php修改那个eml文件的头信息:

我想删除行消息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: "mail@example.com" <mail@example.com>
To: Recipient <test@test.de>, Recipient <test@test.de>, 
Recipient <test@test.de>
Date: Fri, 19 Jul 2013 08:38:42 +0200
Subject: EG...
Thread-Topic: EG...
Thread-Index: Ac6ESpw8LCpOq4iNTOa02MkB6MTlsQ==
Message-ID: <20130719063842.62C961608B7@mail.local>
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

1 个答案:

答案 0 :(得分:0)

这是一个相对简单的preg_replace问题....这应该可以满足您的需求。

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