2013-07-19 5 views
1

는 PHP와 그 EML 파일의 헤더 정보를 수정하고자 i`d 파일 :제거 또는 수정 헤더 정보

내가 라인 메시지 ID를 제거 할을하고 난에서 메일 adresses를 변경하려면 라인 To. 예를 들어, 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

이메일 헤더가 어떻게 보이는지 보여 주셔서 감사합니다 ... 목표를 달성하기 위해 수행 한 작업을 Google에 표시 할 수 있습니까? – 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]><---- 해당 줄도 삭제해야합니다. 날짜 : 금요일, 7 월 19 일, 금요일 08:38:42 +0200 –

+0

아니요, 까다로운 해결책을 찾지 못했습니다 : $ emailx = file_get_contents ("test.eml"); $ emailx = 폭발 ("\ n \ n", $ emailx); $ email = $ emailx [0]; $ email = preg_replace ('/^Message-ID :. * \ n/m', '', $ email); $ email = preg_replace ('/^To : (. * \ n) * Date :/m', 'To : [email protected] \ nDate : ", $ email); $ cc = $ email. "\ n \ n". $ emailx [1]; file_put_contents ("test1.eml", $ cc); 문자열 (전체 메일)이 너무 크면 아파치가 충돌하기 때문에 \ n \ n 이후에 폭발해야했습니다 ... 더 나은 해결책이 있습니까? –