Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Correos gestor</title>
- <!-- Custom style -->
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css">
- <style>
- pre {
- white-space: pre;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
- </style>
- </head>
- <body>
- <div class="alert alert-info alert-dismissable">Correos</div>
- <?php
- error_reporting(0);
- // Multiple email account
- $emails = array(
- array(
- 'no' => '1',
- 'label' => 'Inbox Email 1',
- 'host' => '{imap.gmail.com:993/imap/ssl}INBOX',
- 'username' => 'claudia.ferreiro@simbiosys.es',
- 'password' => 'ccf2017:'
- )
- );
- foreach ($emails as $email) {
- $read = imap_open($email['host'],$email['username'],$email['password']) or die('<div class="alert alert-danger alert-dismissable">Cannot connect to yourdomain.com: ' . imap_last_error().'</div>');
- $array = imap_search($read,'ALL');
- if($array) {
- $html = '';
- rsort($array);
- $html.= '<div class="panel panel-default">
- <div class="panel-heading">
- '.$email['label'].'
- </div>
- <div class="panel-body">
- <div class="panel-group" id="accordion">';
- foreach($array as $result) {
- $overview = imap_fetch_overview($read,$result,0);
- $message = imap_body($read,$result,0);
- $message = quoted_printable_decode($message); // <-- add this line
- $reply = imap_headerinfo($read,$result,0);
- $html.= ' <div class="panel panel-default">
- <div class="panel-heading">
- <h4 class="panel-title">
- <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#'.$email['no'].$result.'">
- <span class="subject">'. iconv_mime_decode((substr(strip_tags($overview[0]->subject),0,50)),0,"UTF-8").'.. </span>
- | |
- <span class="from">'. iconv_mime_decode(($overview[0]->from),0,"UTF-8").'</span>
- | |
- <span class="date">on '. quoted_printable_decode($overview[0]->date).'</span>
- </a>
- </h4>
- </div>
- <div id="'.$email['no'].$result.'" class="panel-collapse collapse">
- <div class="panel-body">
- <pre>'.$message.'<hr>From: '.$reply->from[0]->mailbox.'@'.$reply->from[0]->host.'</pre>
- </div>
- </div>
- </div>';
- }
- $html.= '</div>
- </div>
- </div>';
- echo $html;
- }
- imap_close($read);
- }
- ?>
- <!-- Javascript -->
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement