| 
<?php
 require_once 'getEmail.class.php';
 
 $email = new processEmail();
 
 $email->server = "{imap.gmail.com:993/imap/ssl/novalidate-cert}";
 
 /**
 * Your login details go here
 */
 $email->login = "[email protected]";
 $email->password = "password123";
 
 /**
 * If you want to delete emails after getting them, set this to true - ideal for a ticketing system
 */
 $email->deleteAfterRetr = false;
 
 /**
 * Test the connection before hand
 */
 try {
 $valid = $email->testConnection(); // Test the connection
 } catch (processEmailException $e) {
 die('ERROR: ' . $e->getMessage());
 }
 
 try {
 if ($valid) { // So everything is okay with the connection
 $email->connect();
 $email->getMessages();
 }
 
 } catch (processEmailException $e) {
 die('ERROR: ' . $e->getMessage());
 }
 
 // Quick and dirty output to show the example
 
 ?>
 <table width='100%'>
 <thead>
 <th>Timestamp</th>
 <th>From</th>
 <th>Attachments</th>
 <th>Summary of email</th>
 </thead>
 <tbody>
 <?php
 foreach ($email->messages as $message) {
 ?>
 <tr>
 <td>
 <?php echo $message->date; ?>
 </td>
 <td>
 <?php echo $message->senderAddress; ?>
 </td>
 <td>
 <?php foreach ($message->attachments as $attachment) {
 echo $attachment->filename . '<br />'; // This could be extended so that the $attachment->rawdata gets written to a file and can be called via href
 }
 ?>
 </td>
 <td>
 <?php echo htmlspecialchars(substr($message->message, 0, 250)); ?>
 </td>
 </tr>
 
 <?php
 } //foreach
 ?>
 </tbody>
 </table>
 
 
 |