function display_message($auth_user, $accountid, $messageid, $fullheaders)
{
    //show an email message
    global $table_width;
    $buttons = array();
    $buttons[0] = 'reply';
    $buttons[1] = 'reply-all';
    $buttons[2] = 'forward';
    $buttons[3] = 'delete';
    if ($fullheaders) {
        $buttons[4] = 'hide-headers';
    } else {
        $buttons[4] = 'show-headers';
    }
    $message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
    if (sizeof($message) == 0) {
        echo "<p style=\"padding-bottom: 100px\">Cannot retrieve message number " . $messageid . ".</p>";
    } else {
        $message = pretty_all($message);
    }
    ?>
  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#cccccc"><strong>Subject:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[subject];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>From:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[fromaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>To:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[toaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>CC:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[ccaddress];
    ?>
</strong></td>
  </tr>
  <tr>
    <td bgcolor="#cccccc"><strong>Received:</strong></td>
    <td bgcolor="#cccccc"><strong><?php 
    echo $message[date];
    ?>
</strong></td>
  </tr>
  </table>

  <?php 
    display_toolbar($buttons, "&messageid={$messageid}");
    ?>
  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#cccccc">
    <?php 
    echo $message[fullheaders];
    ?>
    </td>
  </tr>
  </table>

  <table width="<?php 
    echo $table_width;
    ?>
" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td>
    <?php 
    echo $message[body];
    ?>
    </td>
  </tr>
  </table>
<?php 
}
function display_message($auth_user, $accountid, $messageid, $fullheaders)
{
    //show an email message
    global $table_width;
    $buttons = array();
    $buttons[0] = 'reply';
    $buttons[1] = 'reply-all';
    $buttons[2] = 'forward';
    $buttons[3] = 'delete';
    if ($fullheaders) {
        $buttons[4] = 'hide-headers';
    } else {
        $buttons[4] = 'show-headers';
    }
    $message = retrieve_message($auth_user, $accountid, $messageid, $fullheaders);
    if (sizeof($message) == 0) {
        echo "cannot retrieve message number {$messageid}" . '.<br /><br /><br /><br /><br />';
    } else {
        $message = pretty_all($message);
        ?>
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> Subject: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[subject];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> From: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[fromaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> To: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[toaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>
    <td bgcolor = '#cccccc'>
      <b> CC: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[ccaddress];
        ?>
 </b>
    </td>
  </tr>
  <tr>    
    <td bgcolor = '#cccccc'>
      <b> Received: </b>
    </td>
    <td bgcolor = '#cccccc'>
      <b> <?php 
        echo $message[date];
        ?>
 </b>
    </td>
  </tr>
  </table>
  
  <?php 
        display_toolbar($buttons, "&messageid={$messageid}");
        ?>
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td bgcolor = '#cccccc'>
  
    <?php 
        echo $message[fullheaders];
        ?>
  
    </td>
  </tr>
  </table>
  
  <table width = <?php 
        echo $table_width;
        ?>
 cellpadding = 4 cellspacing = 0  border = 0>
  <tr>
    <td>
  
    <?php 
        echo $message[body];
        ?>
  
    </td>
  </tr>
  </table>
<?php 
    }
}