So TMail is a mail checker thing that I wrote some while ago becuase I didn't like people going to
http://mysite.com/webmail and seeing the CPanel logo and everything (I'm very nit-picky...?)
So the problem is that I made it for text-message based e-mails with attachements.
So here's the code:
PHP Code:
<?php
$x = $_GET['id'];
$msg_info = imap_headerinfo($mbox,$x);
$from = $msg_info->from;
$from_addr = $from[0]->mailbox ."@". $from[0]->host;
$subject= $msg_info->fetchsubject;
$person = $from[0]->personal;
if($subject==""){
$subject = $msg_info->subject;
}
$info = imap_fetchstructure($mbox, $x);
$numparts = count($info->parts);
$message = imap_fetchbody($mbox,$x,"1");
if($message==""){
$message = imap_body($mbox,$x);
// Take out < and > and put in some line breaks.
$message = str_replace("<","<",$message);
$message = str_replace(">",">",$message);
$message = str_replace("\n","<br />", $message);
}
if(strpos($message,"<br>")===FALSE||strpos($message,"<br />")===FALSE){
$message = str_replace("<","<",$message);
$message = str_replace(">",">",$message);
$message = str_replace("\n","<br />", $message);
}
?>
<table width="90%" class="center" cellspacing="0" cellpadding="0">
<tr><td class="nav" colspan="10">
<a href="?x=home" class="nav"><img src="home.gif" alt="" /></a><a href="?x=home" class="nav"> Home</a>
<a href="?x=config" class="nav"><img src="config.gif" alt="" /></a><a href="?x=config" class="nav"> Configuration</a>
<a href="?x=reply&id=<? echo $id; ?>" class="nav"><img src="mail.gif" alt="" /></a><a href="?x=reply&id=<? echo $id; ?>" class="nav"> Reply</a>
<a href="logout.php" class="nav"><img src="back.gif" alt="" /></a><a href="logout.php" class="nav"> Logout</a>
</td>
</tr>
<tr><td class="content">From: <?php echo $person." <".$from_addr.">"; ?></td></tr>
<tr><td class="nav"><?php echo $subject; ?></td></tr>
<tr><td class="content"><?php echo $message; ?></td></tr>
<?php
if($numparts>1){
?>
<tr><td class="content"><br />
<table width="60%" class="center" cellspacing="0" cellpadding="0">
<tr><td class="nav" colspan="2"><strong>Attachements:</strong></td></tr>
<?php
$i = 0;
foreach ($info->parts as $part)
{
if (strtolower($part->disposition) == "attachment")
{
$i++;
echo "<tr><td class=\"content\" width=\"5%\">".$i."</td>";
echo "<td width=\"95%\" class=\"content textcenter\"><a href=\"download_attachement.php?x=".$x."&attid=".$i."\" target=\"_blank\">".$part->dparameters[0]->value."</a></td></tr>";
}
}
?>
</table><br /></td></tr>
<?php
}
?>
</tablE>
Rather messy...
When an HTML message come it shows:
And text-based:
Hope you can help...
(The site is
http://email.wallio.net you can login with any e-mail that you've created in CPanel)
(My goal was to make something like
http://mail2web.com)