Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(4000);
- // Connect to gmail
- $imapPath = '{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'usenamer@gmail.com';
- $password = 'password';
- // try to connect
- $inbox = imap_open($imapPath,$username,$password,NULL,1) or die('Cannot connect to Gmail: ' . print_r(imap_errors()));
- $emails = imap_search($inbox,'UNSEEN');
- $output = '';
- foreach($emails as $mail) {
- $headerInfo = imap_headerinfo($inbox,$mail);
- $output .= $headerInfo->subject.'<br/>';
- $output .= $headerInfo->toaddress.'<br/>';
- $output .= $headerInfo->date.'<br/>';
- $output .= $headerInfo->fromaddress.'<br/>';
- $output .= $headerInfo->reply_toaddress.'<br/>';
- $emailStructure = imap_fetchstructure($inbox,$mail);
- if(!isset($emailStructure->parts)) {
- $output .= imap_body($inbox, $mail, FT_PEEK);
- } else {
- //
- }
- echo $output;
- $output = '';
- }
- // colse the connection
- imap_expunge($inbox);
- imap_close($inbox);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement