Email question
| From: | Jake | Date: | Wed, 31 Oct 2007 21:38:11 +0000 |
| Subject: | Email question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-263895@lists.php.net to get a copy of this message | ||
What is a =20 at the end of a line in an email? Is it some kind of whitespace line return or
something? it only seems to appear when there is whitespace that is linewrapping. I have googled and
googled for it, but havn't found anything yet. here's my function...
buffer is a complete correctly formatted email from any standard client.
In most of my tests, everything works fine, but a test with many spaces trying to wrap them, it
gives a =20 in the email result.
It's probably simple.. sitting here too long and its halloween!!!!!!
Thanks,
Jake
function parseEmail($buffer)
{
$pattern1 = '/^From: \"(.*)\" <(.*)\@(.*)\.(.*)>/';
$pattern2 = '/^From: (.*)\@(.*)\.(.*)/';
$pattern3 = '/^Subject: (.*)/';
$pattern4 = 'Content-Type: text/plain;';
$pattern5 = 'Content-Type: text/html;';
$temp = explode("\n", $buffer);
foreach($temp as $key => $value)
{
if (preg_match($pattern1, $value, $match))
{
$from = "\"$match[1]\" <$match[2]@$match[3].$match[4]>";
}
else if (preg_match($pattern2, $value, $match))
{
$from = "\"\" <$match[1]@$match[2].$match[3]>";
}
if (preg_match($pattern3, $value, $match))
{
$subject = $match[1];
}
if ($pos = strpos($value, $pattern4) !== false)
{
$begin = $key;
}
if ($pos = strpos($value, $pattern5) !== false)
{
$end = $key - 1;
}
}
if (!isset($end))
{
$end = count($temp) - 1;
}
$data = "Below is the email you sent to consolidators@nittanytravel.com:\n\n";
$start = 'false';
while($begin < $end)
{
if ($start == 'false')
{
if (empty($temp[$begin]))
{
$start = 'true';
}
}
else
{
$data .= chop($temp[$begin]) . "\n";
}
$begin++;
}
return "$from|$subject|$data";
}