Advertisement
claukiller

emailreader

Mar 22nd, 2018
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Correos gestor</title>
  8. <!-- Custom style -->
  9. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css">
  10. <style>
  11. pre {
  12. white-space: pre;
  13. white-space: pre-wrap;
  14. word-wrap: break-word;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div class="alert alert-info alert-dismissable">Correos</div>
  20. <?php
  21. error_reporting(0);
  22.  
  23. // Multiple email account
  24. $emails = array(
  25. array(
  26. 'no' => '1',
  27. 'label' => 'Inbox Email 1',
  28. 'host' => '{imap.gmail.com:993/imap/ssl}INBOX',
  29. 'username' => 'claudia.ferreiro@simbiosys.es',
  30. 'password' => 'ccf2017:'
  31. )
  32. );
  33.  
  34. foreach ($emails as $email) {
  35.  
  36. $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>');
  37.  
  38. $array = imap_search($read,'ALL');
  39.  
  40. if($array) {
  41.  
  42. $html = '';
  43.  
  44. rsort($array);
  45.  
  46. $html.= '<div class="panel panel-default">
  47. <div class="panel-heading">
  48. '.$email['label'].'
  49. </div>
  50. <div class="panel-body">
  51. <div class="panel-group" id="accordion">';
  52.  
  53. foreach($array as $result) {
  54.  
  55. $overview = imap_fetch_overview($read,$result,0);
  56. $message = imap_body($read,$result,0);
  57. $message = quoted_printable_decode($message); // <-- add this line
  58. $reply = imap_headerinfo($read,$result,0);
  59.  
  60. $html.= ' <div class="panel panel-default">
  61. <div class="panel-heading">
  62. <h4 class="panel-title">
  63. <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#'.$email['no'].$result.'">
  64. <span class="subject">'. iconv_mime_decode((substr(strip_tags($overview[0]->subject),0,50)),0,"UTF-8").'.. </span>
  65. | |
  66. <span class="from">'. iconv_mime_decode(($overview[0]->from),0,"UTF-8").'</span>
  67. | |
  68. <span class="date">on '. quoted_printable_decode($overview[0]->date).'</span>
  69. </a>
  70. </h4>
  71. </div>
  72. <div id="'.$email['no'].$result.'" class="panel-collapse collapse">
  73. <div class="panel-body">
  74. <pre>'.$message.'<hr>From: '.$reply->from[0]->mailbox.'@'.$reply->from[0]->host.'</pre>
  75. </div>
  76. </div>
  77. </div>';
  78.  
  79. }
  80.  
  81. $html.= '</div>
  82. </div>
  83. </div>';
  84.  
  85. echo $html;
  86.  
  87. }
  88.  
  89. imap_close($read);
  90.  
  91. }
  92.  
  93. ?>
  94.  
  95. <!-- Javascript -->
  96. <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  97. <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement