Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. $hostname = '{imap.mycat.cz:143/imap/novalidate-cert}INBOX';
  4. $username = '';
  5. $password = '';
  6.  
  7. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to mail server: ' . imap_last_error());
  8. $emails = imap_search($inbox,'ALL');
  9.  
  10. $data = [];
  11.  
  12.  
  13. if($emails) {
  14.     $output = '';
  15.     rsort($emails);
  16.  
  17.     foreach($emails as $email_number)
  18.     {
  19.         $mail_data = [];
  20.         $overview = imap_fetch_overview($inbox,$email_number,0);
  21.         $structure = imap_fetchstructure($inbox, $email_number);
  22.         $header = imap_header($inbox, $email_number);
  23.         $frome = $header->from;
  24.  
  25.         $mail_data['from'] = quoted_printable_decode(imap_utf8($overview[0]->from));
  26.         $mail_data['date'] = utf8_decode(imap_utf8($overview[0]->date));
  27.         $mail_data['subject'] = quoted_printable_decode(imap_utf8($overview[0]->subject));
  28.         $mail_data['message'] = imap_base64(imap_fetchbody($inbox,$email_number,1));
  29.  
  30.        
  31.         $data[] = $mail_data;
  32.     }
  33. }
  34.  
  35. imap_close($inbox);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement