Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $imapPath = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
- $username = 'example@gmail.com';
- $password = 'password.';
- $inbox = imap_open($imapPath, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
- $emails = imap_search($inbox, 'ALL');
- //$count=0;
- foreach ($emails as $mail) {
- $overview = imap_fetch_overview($inbox, $mail);
- $u_id = $overview[0]->uid;
- if ($u_id == 343) { //12 is message unigue id
- $headerInfo = imap_headerinfo($inbox, $mail);
- $structure = imap_fetchstructure($inbox, $mail);
- if (isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
- $part = $structure->parts[1];
- $message = imap_fetchbody($inbox, $mail, '2');
- if ($part->encoding == 3) {
- $message = imap_base64($message);
- echo $message;
- echo "<br><b>base64</b><br>";
- } else if ($part->encoding == 1) {
- $message = imap_8bit($message);
- echo $message;
- echo "<br><b>imap_8bit</b><br>";
- } else {
- $message = imap_qprint($message);
- echo $message;
- echo "<br><b>imap_qprint</b><br>";
- }
- }
- }
- }
- imap_expunge($inbox);
- imap_close($inbox);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement