Skip to content

Commit

Permalink
Add support to wp-mail.php for quoted-printable Content-Transfer-Enco…
Browse files Browse the repository at this point in the history
…ding. Props Nazgul. fixes #2460

git-svn-id: http://svn.automattic.com/wordpress/trunk@5188 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
rob1n committed Apr 6, 2007
1 parent 4a5335a commit 7068240
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions wp-mail.php
Expand Up @@ -24,10 +24,10 @@


$content = ''; $content = '';
$content_type = ''; $content_type = '';
$content_transfer_encoding = '';
$boundary = ''; $boundary = '';
$bodysignal = 0; $bodysignal = 0;
$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
foreach ($message as $line) : foreach ($message as $line) :
if (strlen($line) < 3) $bodysignal = 1; if (strlen($line) < 3) $bodysignal = 1;


Expand All @@ -40,6 +40,12 @@
$content_type = explode(';', $content_type); $content_type = explode(';', $content_type);
$content_type = $content_type[0]; $content_type = $content_type[0];
} }
if (preg_match('/Content-Transfer-Encoding: /i', $line)) {
$content_transfer_encoding = trim($line);
$content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding)-14);
$content_transfer_encoding = explode(';', $content_transfer_encoding);
$content_transfer_encoding = $content_transfer_encoding[0];
}
if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) { if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
$boundary = trim($line); $boundary = trim($line);
$boundary = explode('"', $boundary); $boundary = explode('"', $boundary);
Expand Down Expand Up @@ -111,11 +117,16 @@
$content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
} }
$content = trim($content); $content = trim($content);

if (stripos($content_transfer_encoding, "quoted-printable") !== false) {
$content = quoted_printable_decode($content);
}

// Captures any text in the body after $phone_delim as the body // Captures any text in the body after $phone_delim as the body
$content = explode($phone_delim, $content); $content = explode($phone_delim, $content);
$content[1] ? $content = $content[1] : $content = $content[0]; $content[1] ? $content = $content[1] : $content = $content[0];


echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n"; echo "<p><b>Content-type:</b> $content_type, <b>Content-Transfer-Encoding:</b> $content_transfer_encoding, <b>boundary:</b> $boundary</p>\n";
echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';


$content = trim($content); $content = trim($content);
Expand Down Expand Up @@ -161,4 +172,4 @@


$pop3->quit(); $pop3->quit();


?> ?>

0 comments on commit 7068240

Please sign in to comment.