Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2. /* connect to gmail */
  3. $hostname = '{imap.villagarden.eu:143/imap/tls/novalidate-cert}INBOX';
  4. $username = 'info@villagarden.eu';
  5. $password = 'villagarden';
  6.  
  7.  
  8. /* try to connect */
  9. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to inbox: ' . print_r(imap_errors()));
  10.  
  11. /* grab emails */
  12. $emails = imap_search($inbox,'ALL');
  13.  
  14. /* if emails are returned, cycle through each... */
  15. if($emails) {
  16.    
  17.     /* begin output var */
  18.     $output = '';
  19.    
  20.     /* put the newest emails on top */
  21.     rsort($emails);
  22.    
  23.     /* for every email... */
  24.     foreach($emails as $email_number) {
  25.        
  26.         /* get information specific to this email */
  27.         $overview = imap_fetch_overview($inbox,$email_number,0);
  28.         $message = imap_fetchbody($inbox,$email_number,1);
  29.        
  30.         /* output the email header information */
  31.         $output.= '<div class="mail"><div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  32.         $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  33.         $output.= 'From:<span class="from">'.$overview[0]->from.'</span>';
  34.         $output.= '<span class="date">on '.$overview[0]->date.'</span>';
  35.         $output.= '</div>';
  36.        
  37.         /* output the email body */
  38.         $output.= '<div class="body">'.$message.'</div></div>';
  39.     }
  40.    
  41.     echo $output;
  42. }
  43.  
  44. /* close the connection */
  45. imap_close($inbox);
  46. ?>
  47. <html>
  48.     <head>
  49.         <style>
  50.         body {
  51.             font-size: 16px;
  52.             padding: 30px;
  53.         }
  54.         .read {
  55.             background-color: #f1f1f1;
  56.             padding: 15px;
  57.         }
  58.         .unread {
  59.             color: red;
  60.         }
  61.         .subject {
  62.             font-weight: 700;
  63.         }
  64.         .from {
  65.             font-style: italic;
  66.         }
  67.         .date {
  68.             font-size: 13px;
  69.         }
  70.         .body {
  71.             padding: 15px;
  72.         }
  73.         .mail {
  74.             border: 1px solid #222;
  75.         }
  76.         </style>
  77.     </head>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement