" ) ; } $link = imap_open( "{imap.gmail.com:993/imap/ssl}INBOX", $gmail_username, $gmail_password ) or exit( "Connection aborted: " . imap_last_error() ) ; $mails = imap_search( $link, 'ALL' ) ; rsort( $mails ) ; $total = count( $mails ) ; if ( isset( $_GET['page'] ) ) { if ( is_numeric( $_GET['page'] ) ) { $begin = round( $_GET['page'], 0 ) * $perpage ; } else { $begin = $total ; } } else { $begin = $total ; } echo "

FETCH EMAIL

" ; for ( $i = $begin; $i >= $begin - $perpage; $i-- ) { if ( $i <= $total ) { $overview = imap_fetch_overview( $link, $i, 0 ) ; $message = imap_fetchbody( $link, $i, 2 ) ; $message = preg_replace( "@@is", "", $message ) ; $message = strip_tags( $message ) ; $read = ( $overview[0]->seen == 0 ) ? 'NOT READ YET' : 'ALREADY READ' ; echo "

[ $i ]. SUBJECT : {$overview[0]->subject} || SENT FROM: {$overview[0]->from} || SENT AT: {$overview[0]->date} || $read

{$message}
" ; } } echo "
" ; // pagination echo "" ; ?>