<?php
// Your Server and port. Can either be a domain name or IP address of the server
$server 'imap.host.com';
$port '143';

// Mailbox you want to be checked
$mailbox 'INBOX';

// Username and password to access server
$username 'postmaster@email';
$password 'password';

// Flags - leave these unless you know what you are doing. 
// detials can be found here: http://uk2.php.net/imap-open 
$flags '/notls/readonly/imap';

echo 
'<?xml version="1.0"?>';
?>

<rss version="2.0">
<channel>
    <title>Mail</title>
    <link>http://e26.co.uk/</link>
    <description>The latest web mail</description>
<?php

$connection 
imap_open("{".$server.":".$port.$flags."}".$mailbox$username$password);
$msgs imap_num_msg($connection);
if(
$msgs 0) { // if any new messages
    
for($i 1$i <= $msgs$i++){ // for each message
        
$email get_object_vars(imap_headerinfo($connection$i)); // get message info
        
        
$description 'To: '.htmlentities($email['toaddress'])."<br />";
        
$description .= 'From: '.htmlentities($email['fromaddress'])."<br />";
        
$description .= 'Date: '.$email['date']."<br />";
        
$description .= 'Subject: '.htmlentities($email['subject'])."<br />";
        
        print 
"<item>\n\t";
        print 
"<title>".htmlentities($email['subject'])."</title>\n\t";
        print 
"<link>#</link>\n\t";
        print 
"<description>$description</description\n\t";
        print 
"<pubDate>".$email['date']."</pubDate>\n\t";
        print 
"</item>\n";
    }

imap_close($connection);
?>
</channel>
</rss>