Bonjour à tous,
J'ai le même problème concernant un header d'email sur plusieurs lignes (Authentication-Results), et effectivement en ajoutant l'option "s" à la REGEX, on ignore le retour chariot.
Cependant, j'aimerai ignorer le retour chariot, jusqu'à ce que la regex trouve un retour chariot collé à un caractère, ce qui signifie que l'on a atteint un nouveau champ :
Données :
Reporting-MTA: dns; mail.example.com
Source-IP: 192.0.2.1
Authentication-Results: mail.example.com;
spf=fail smtp.mail=somespammer@example.com
Reported-Domain: example.net
Reported-Uri:
http://example.net/earn_money.html
Reported-Uri: mailto:user@example.com
Removal-Recipient:
user@example.com
REGEX qui fonctionne pour les headers sur une ligne :
/Authentication-Results: (.+)/i
Réponse :
Array
(
[0] => Array
(
[0] => Authentication-Results: mail.example.com;
)
[1] => Array
(
[0] => mail.example.com;
)
)
=> Il manque la ligne contenant :
spf=fail smtp.mail=somespammer@example.com
Test avec l'option s :
/Authentication-Results: (.+)/is
Array
(
[0] => Array
(
[0] => Authentication-Results: mail.example.com;
spf=fail smtp.mail=somespammer@example.com
Reported-Domain: example.net
Reported-Uri:
http://example.net/earn_money.html
Reported-Uri: mailto:user@example.com
Removal-Recipient:
user@example.com
)
[1] => Array
(
[0] => mail.example.com;
spf=fail smtp.mail=somespammer@example.com
Reported-Domain: example.net
Reported-Uri:
http://example.net/earn_money.html
Reported-Uri: mailto:user@example.com
Removal-Recipient:
user@example.com
)
)
=> Il faudrai que je coupe mon résultat à partir de "\nReported-Domain:", donc à partir de
?
Si c'est le cas je ne sais pas comment construire correctement ma REGEX avec ces informations... si quelqu'un pouvait m'expliquer...
Merci d'avance
Partager