Created
January 25, 2011 08:52
-
-
Save sebm/794680 to your computer and use it in GitHub Desktop.
Explanation of UTF-8 header testing for Symfony / Swift Mailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$expectedHeaderMessage = Swift_Message::newInstance() | |
->setSubject('Información') | |
->setCharset('utf-8') | |
; | |
$msgString = $expectedHeaderMessage->toString(); | |
/* | |
echo $msgString: | |
Message-ID: <[email protected]> | |
Date: Tue, 25 Jan 2011 10:06:52 +0000 | |
Subject: =?utf-8?Q?Informaci=C3=B3n?= | |
From: | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset=utf-8 | |
Content-Transfer-Encoding: quoted-printable | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$matches = array(); | |
$pattern = '/\nSubject: ([A-z0-9\-\?\= ]*).*\n/'; | |
preg_match($pattern, $msgString, $matches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$browser-> | |
info("The UTF-8 header is as we expect it to be")-> | |
with('mailer')->begin()-> | |
checkHeader('Subject', '/'.preg_quote($matches[1]).'/')-> | |
end() | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment