<?php
$hostname = '{mail.runbox.com:993/notls}INBOX';
$username = 'dubi@runbox.com';
$password = 'Qwer1234'; error_reporting(0);
$inbox = imap_open($hostname, $username, $password);

if($inbox) {
$total_emails = imap_num_msg($inbox);
if($total_emails > 0) {
$last_email_index = $total_emails;
$overview = imap_fetch_overview($inbox, $last_email_index, 0);
$message = imap_fetchbody($inbox, $last_email_index, 1);
echo "Subject: " . $overview[0]->subject . "\n";
echo "From: " . $overview[0]->from . "\n";
echo "Body: " . $message;
}
else { echo "Inbox is empty."; }
imap_close($inbox);
}
else { echo 'Cannot connect to email server: ' . imap_last_error(); }
