mail : getHeaders function added

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5827 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-12-09 20:42:39 +00:00
parent abd8b70ad1
commit 5f52085461
2 changed files with 108 additions and 18 deletions

View File

@@ -133,4 +133,94 @@ class mailTest extends PHPUnit_Framework_TestCase
array ("name" => "",
"mail" => "titi@titi.com")));
}
/** Read all the headers and return them as JSON object
*/
public function testHeadersToJSON1 ()
{
$mail = new mail ();
$mail->readMail ( // {{{
"Return-Path: <dominique.fournier@grenoble.cnrs.fr>
Delivered-To: dominique@fournier38.fr
Received: from mail-postfix-mx.fournier38.fr ([192.168.1.103])
by mail-dovecot.fournier38.fr with LMTP
id z706BqQt7V15IAAAA28uxw
(envelope-from <dominique.fournier@grenoble.cnrs.fr>)
for <dominique@fournier38.fr>; Sun, 08 Dec 2019 18:06:44 +0100
Received: from mailgw-out1.grenoble.cnrs.fr (mailgw-out1.grenoble.cnrs.fr [147.173.1.68])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail-postfix-mx.fournier38.fr (Postfix) with ESMTPS id 8A2DF820733
for <dominique@fournier38.fr>; Sun, 8 Dec 2019 18:06:43 +0100 (CET)
DMARC-Filter: OpenDMARC Filter v1.3.2 mail-postfix-mx.fournier38.fr 8A2DF820733
Delivered-To: dominique.fournier@grenoble.cnrs.fr
Received: from [192.168.1.154] (82-64-55-197.subs.proxad.net [82.64.55.197])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by mailgw-out1.grenoble.cnrs.fr (Postfix) with ESMTPSA id 458EDBFCE4
for <dominique@fournier38.fr>; Sun, 8 Dec 2019 18:08:06 +0100 (CET)
From: Dominique Fournier <dominique.fournier@grenoble.cnrs.fr>
Subject: Analyse de texte
To: Dominique Fournier / Fournier38 <dominique@fournier38.fr>
Message-ID: <81d7982f-7fee-96b4-078f-a6365234356f@grenoble.cnrs.fr>
Date: Sun, 8 Dec 2019 18:08:06 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.2
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Authentication-Results: mail-postfix-mx.fournier38.fr;
dkim=none;
dmarc=none;
spf=pass (mail-postfix-mx.fournier38.fr: domain of dominique.fournier@grenoble.cnrs.fr designates 147.173.1.68 as permitted sender) smtp.mailfrom=dominique.fournier@grenoble.cnrs.fr
X-Spamd-Bar: --------------------------------------------------------------------------------------------------
https://openclassrooms.com/fr/courses/4470541-analysez-vos-donnees-textuelles/4854971-nettoyez-et-normalisez-les-donnees
http://www.nltk.org/nltk_data/
http://www.cs.cmu.edu/~ralf/langid.html
");
// }}}
$this->assertSame ($mail->getHeaders (), array (
["Return-Path" => "<dominique.fournier@grenoble.cnrs.fr>\n"],
["Delivered-To" => "dominique@fournier38.fr\n"],
["Received" => "from mail-postfix-mx.fournier38.fr ([192.168.1.103])
by mail-dovecot.fournier38.fr with LMTP
id z706BqQt7V15IAAAA28uxw
(envelope-from <dominique.fournier@grenoble.cnrs.fr>)
for <dominique@fournier38.fr>; Sun, 08 Dec 2019 18:06:44 +0100\n"],
["Received" => "from mailgw-out1.grenoble.cnrs.fr (mailgw-out1.grenoble.cnrs.fr [147.173.1.68])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail-postfix-mx.fournier38.fr (Postfix) with ESMTPS id 8A2DF820733
for <dominique@fournier38.fr>; Sun, 8 Dec 2019 18:06:43 +0100 (CET)\n"],
["DMARC-Filter" => "OpenDMARC Filter v1.3.2 mail-postfix-mx.fournier38.fr 8A2DF820733\n"],
["Delivered-To" => "dominique.fournier@grenoble.cnrs.fr\n"],
["Received" => "from [192.168.1.154] (82-64-55-197.subs.proxad.net [82.64.55.197])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by mailgw-out1.grenoble.cnrs.fr (Postfix) with ESMTPSA id 458EDBFCE4
for <dominique@fournier38.fr>; Sun, 8 Dec 2019 18:08:06 +0100 (CET)\n"],
["From" => "Dominique Fournier <dominique.fournier@grenoble.cnrs.fr>\n"],
["Subject" => "Analyse de texte\n"],
["To" => "Dominique Fournier / Fournier38 <dominique@fournier38.fr>\n"],
["Message-ID" => "<81d7982f-7fee-96b4-078f-a6365234356f@grenoble.cnrs.fr>\n"],
["Date" => "Sun, 8 Dec 2019 18:08:06 +0100\n"],
["User-Agent" => "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.2.2\n"],
["MIME-Version" => "1.0\n"],
["Content-Type" => "text/plain; charset=utf-8; format=flowed\n"],
["Content-Language" => "en-US\n"],
["Content-Transfer-Encoding" => "7bit\n"],
["Authentication-Results" => "mail-postfix-mx.fournier38.fr;
dkim=none;
dmarc=none;
spf=pass (mail-postfix-mx.fournier38.fr: domain of dominique.fournier@grenoble.cnrs.fr designates 147.173.1.68 as permitted sender) smtp.mailfrom=dominique.fournier@grenoble.cnrs.fr\n"],
["X-Spamd-Bar" => "--------------------------------------------------------------------------------------------------\n"],
));
}
}