<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once("auth.php");
include("email_config.php");
include("email_functions.php");
if($id) {
  /* POP3-Connect: */
  connect();
  command("RETR $id");
  while (($headerArray[] = getLine()) != "")

  $headers = getHeaders($headerArray);

  $subject = htmlspecialchars(mimeHeaderDecode($headers["subject"]));
  $date = dateFormat(strtotime($headers["date"]),"datetime");

  $sender = getSender($headers["from"]);
  $sender = (isset($sender["email"])) ? $sender["name"]." ".$sender["email"] : $sender["name"];
  $sender = htmlspecialchars(mimeHeaderDecode($sender));

  $recipient = getSender($headers["to"]);
  $recipient = (isset($recipient["email"])) ? $recipient["name"]." ".$recipient["email"] : $recipient["name"];
  $recipient = htmlspecialchars(mimeHeaderDecode($recipient));

  if (isset($headers["cc"])) { $cc = htmlspecialchars(mimeHeaderDecode($headers["cc"])); } else { $cc = "&nbsp;"; }
  if (isset($headers["user-agent"])) $userAgent = $headers["user-agent"];
  if (isset($headers["x-mailer"])) $userAgent = $headers["x-mailer"];
  if (isset($headers["x-newsreader"])) $userAgent = $headers["x-newsreader"];

  echo "<table>";
  for ($i = 0; $i < sizeof($headerArray); $i++) {
        if (!$headerArray[$i]) continue;

        unset($name);
        $value = $headerArray[$i];

        if ($colonPos = strpos($headerArray[$i], ": ")) {
           $name = substr($headerArray[$i], 0, $colonPos + 1);
           $value = substr($headerArray[$i], $colonPos + 2);
        }

        echo "<tr>\n";
        echo "<td>".htmlspecialchars($name)."</td>\n";
        echo "<td>".htmlspecialchars($value)."</td>\n";
        echo "</tr>\n";
  }
  echo "</table><br>&nbsp;<br>";

  /* POP3-Disconnect: */
  command("QUIT");
}
?>
