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]\" <[EMAIL PROTECTED]>";
    }
    else if (preg_match($pattern2, $value, $match))
    {
      $from = "\"\" <[EMAIL PROTECTED]>";
    }

    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 [EMAIL PROTECTED]:\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";
}

Reply via email to