icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » TMail - Errors with HTML messages

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old October 21st, 2005, 3:55 PM   #1 (permalink)
DemonicAngel
Super #1
 
twirp's Avatar
 
Joined in Aug 2004
Lives in Wherever The World Takes Me
Hosted on Pass76
1,847 posts
Gave thanks: 28
Thanked 35 times
TMail - Errors with HTML messages

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("<","&lt;",$message);
    
$message str_replace(">","&gt;",$message);
    
$message str_replace("\n","<br />"$message);
}
if(
strpos($message,"<br>")===FALSE||strpos($message,"<br />")===FALSE){
    
$message str_replace("<","&lt;",$message);
    
$message str_replace(">","&gt;",$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">&nbsp; Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="?x=config" class="nav"><img src="config.gif" alt="" /></a><a href="?x=config" class="nav">&nbsp; Configuration</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="?x=reply&id=<? echo $id?>" class="nav"><img src="mail.gif" alt="" /></a><a href="?x=reply&id=<? echo $id?>" class="nav">&nbsp; Reply</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="logout.php" class="nav"><img src="back.gif" alt="" /></a><a href="logout.php" class="nav">&nbsp; Logout</a>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
<tr><td class="content">From: <?php echo $person."&nbsp;&lt;".$from_addr."&gt;"?></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:
Quote:
This is an html based message <http://twirp.net>
http://twirp.net?x=3Dlink
^ really cool page...
And text-based:
Quote:
This is not
an HTML message http://twirp.net
Notice how it looks nice

http://twirp.net/?x=link
^ really cool page
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)
__________________
You wear Vans so high school kids will think that you can skate. He wears Vans because he can skate. TwiRp wears Vans because they were on sale. Pass76 wants Vans.
twirp is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On