+ Reply to Thread
Results 1 to 2 of 2

Thread: print message body in a webpage

  1. #1
    kapo is offline Registered User
    Join Date
    Apr 2009
    Posts
    2
    Downloads
    0
    Uploads
    0

    Default print message body in a webpage

    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:
    <?php
    
    	include("lib/bugs.inc");
    	include("lib/rcube_imap.php");
    	include("lib/rcube_shared.php");
    	include("lib/rcube_mdb2.php");
    	include("lib/rcube_main.php");
    	include("lib/rcube_message.php");
    	include("lib/rcmail.php");
    	include("lib/rcube_config.php");
    	// include("lib/mime.php");
    	// include("lib/rcube_mail_mime.php");
    	
    	$DB = new rcube_mdb2("mysqli://USERNAME:PASSWORD@HOST/DB");
    
    	$imap = new rcube_imap($DB);
    
    	$imap->connect("IMAP.SERVER", "USERNAME", "PASSWORD", 993, "ssl");
    	echo "<br />" . $imap->get_mailbox_name();
    	
    	echo "<br />";
    	foreach($imap->list_mailboxes() as $mailbox)
    		echo "<br />" . $mailbox . "(".$imap->messagecount($mailbox).")";
    
    	echo "<br /><br />";
    	foreach ($imap->list_headers('Trash') as $header) {
    		echo $header->date . " " . $header->uid. " " . $header->from . " " . $header->subject . " :: ";
    		
    		$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

  2. #2
    kapo is offline Registered User
    Join Date
    Apr 2009
    Posts
    2
    Downloads
    0
    Uploads
    0

    Default

    Ok, I found a way to print a raw body:

    Code:
    $head = $imap->get_headers($header->uid, "Trash", TRUE, TRUE);
    	echo $header->uid. " " . $header->from . " " . $header->subject . " :: <br />";
    	echo $imap->get_raw_body($head->uid);
    but I have a lot of problem to convert the body in a correct charset...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts