<?php
include_once('lib/class.imap.php'); $email = new Imap();$inbox = null; $hostname = '{imap.asia.secureserver.net:993/imap/ssl}INBOX';$username = 'ahmad@abconline.us';$password = 'Thisisabode1'; if($email->connect( $hostname, $username, $password )){ //inbox array $inbox = $email->getMessages('html'); } //asort($inbox);//echo'<pre>';//print_r($inbox[0]['message']);//print_r($inbox[1]['message']);//echo'<pre>'; ?> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> <link rel="stylesheet" href='https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css'> </head> <style> body{ padding: 20px 10px 20px 10px; } </style> <div class="container"> <div class="row"> <div class="col-md-12"> <h3 align="center">Email Inbox<a href="mailto:abodepvt@gmail.com"</h3> <hr> <?php if($inbox == null){ echo '<h4>Not connect..</h4>'; exit; }else { ?> <table id="inbox" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>No</th> <th>Subject</th> <th>Name</th> <th>Email</th> <th>Date</th> </tr> </thead> <tbody> <?php $html = ''; $no = 1; foreach ($inbox as $v) { $attachment = ''; if (!empty($v['attachments'])) { foreach ($v['attachments'] as $a) { $attachment .= '<br><a href="'.$a.'" target="_BLANK">'.end(explode('/', $a)).'</a>'; } } $html .= '<tr><td>' . $no . '</td>'; $html .= '<td><a href="#" data-message="'.htmlentities($v['message'].(!empty($attachment) ? '<hr>Attachments:' . $attachment : '')) . '" class="message" data-toggle="modal" data-target="#addModal">'.substr($v['subject'], 0, 120).'</a></td>'; $html .= '<td>' . (empty($v['from']['name']) ? '[empty]' : $v['from']['name']) . '</td>'; $html .= '<td><a href="mailto:'.$v['from']['address'].'?subject=Re:'.$v['subject'].'">'.$v['from']['address'].'</a></td>'; $html .= '<td>' . date('Y-m-d h:i:sa', $v['date']) . '</td></tr>'; $no++; } echo $html; ?> </tbody> </table> <?php } ?> </div> </div> </div> <div id="addModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Message</h4> </div> <div class="modal-body" id="coeg"> </div> </div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" rel="script"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" rel="script"></script>; <script> $(function(){ $('#inbox').DataTable(); $('body').on('click','.message',function(){ var message = $(this).data('message'); $('#coeg').html(message); }); }); </script>
- Download the Imap class from https://github.com/achillesion/PHP-IMAP-Class.
- Think hard and READ the code.
- We are using bootstrap,jquery,and datatables.
- Please check that the imap is availbale on the email address you are using.
- Video link: https://www.youtube.com/watch?v=xFQxTB0awiU

Comments
Post a Comment