Email question
- From: linux@xxxxxxxxxxxxxxxxx ("Jake")
- Date: Wed, 31 Oct 2007 16:38:11 -0500
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@xxxxxxxxxxxxxxxxx:\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";
}
- Follow-Ups:
- Re: [PHP] Email question
- From: "Andrew Ballard"
- Re: [PHP] Email question
- Prev by Date: RE: [PHP] RE: Reaching the PHP mailing list owners
- Next by Date: Re: [PHP] Email question
- Previous by thread: PHP standard vs. Zend Core
- Next by thread: Re: [PHP] Email question
- Index(es):