Author Topic: print message body in a webpage  (Read 2739 times)

Offline kapo

  • Newbie
  • *
  • Posts: 2
print message body in a webpage
« on: April 16, 2009, 07:31:10 PM »
I want to use roundcube API to create a webapplication but i've some problem with the IMAP class.
I want to print in a web page information about a message (like date, subject, sender and body).
This is my code:
Code: [Select]
<?php

include(&
quot;lib/bugs.inc&quot;);
include(&quot;lib/rcube_imap.php&quot;);
include(&quot;lib/rcube_shared.php&quot;);
include(&quot;lib/rcube_mdb2.php&quot;);
include(&quot;lib/rcube_main.php&quot;);
include(&quot;lib/rcube_message.php&quot;);
include(&quot;lib/rcmail.php&quot;);
include(&quot;lib/rcube_config.php&quot;);
// include(&quot;lib/mime.php&quot;);
// include(&quot;lib/rcube_mail_mime.php&quot;);

$DB = new rcube_mdb2(&quot;mysqli://USERNAME:PASSWORD@HOST/DB&quot;);

$imap = new rcube_imap($DB);

$imap->connect(&quot;IMAP.SERVER&quot;, &quot;USERNAME&quot;, &quot;PASSWORD&quot;, 993, &quot;ssl&quot;);
echo &quot;<br />&quot; . $imap->get_mailbox_name();

echo &quot;<br />&quot;;
foreach($imap->list_mailboxes() as $mailbox)
echo &quot;<br />&quot; . $mailbox . &quot;(&quot;.$imap->messagecount($mailbox).&quot;)&quot;;

echo &quot;<br /><br />&quot;;
foreach ($imap->list_headers('Trash') as $header) {
echo $header->date . &quot; &quot; . $header->uid. &quot; &quot; . $header->from . &quot; &quot; . $header->subject . &quot; :: &quot;;

$MESSAGE = new rcube_message($header->id$imap);
if (!empty($MESSAGE->headers->charset))
// $imap->set_charset($MESSAGE->headers->charset);

$mbox_name $IMAP->get_mailbox_name();
}
$imap->close();

?>


It works but i can print on page only date, subject and sender... i can't print the message body, can someone help me?

tnx

Offline kapo

  • Newbie
  • *
  • Posts: 2
print message body in a webpage
« Reply #1 on: April 17, 2009, 08:37:21 AM »
Ok, I found a way to print a raw body:

Code: [Select]
$head = $imap->get_headers($header->uid, &quot;Trash&quot;, TRUE, TRUE);
echo $header->uid. &quot; &quot; . $header->from . &quot; &quot; . $header->subject . &quot; :: <br />&quot;;
echo $imap->get_raw_body($head->uid);


but I have a lot of problem to convert the body in a correct charset...