Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = $_REQUEST['u'];
- $password = $_REQUEST['p'];
- $server = '{imap-mail.outlook.com:993/ssl}';
- //$connection = imap_open($server, $username, $password);
- //$msgnos = imap_search($connection, 'RECENT');
- $mbox = imap_open("{imap-mail.outlook.com:993/ssl}", $username, $password);
- if(!$mbox)
- die('????');
- // get information about the current mailbox (INBOX in this case)
- $mboxCheck = imap_check($mbox);
- // get the total amount of messages
- $totalMessages = $mboxCheck->Nmsgs;
- // select how many messages you want to see
- $showMessages = 5;
- // get those messages
- $result = array_reverse(imap_fetch_overview($mbox,($totalMessages-$showMessages+1).":".$totalMessages));
- // iterate trough those messages
- foreach ($result as $mail) {
- echo 'vkl';
- print_r($mail);
- echo 'lvk';
- echo '<br>';
- echo mb_decode_mimeheader($mail->subject);
- echo '<br>';
- // if you want the mail body as well, do it like that. Note: the '1.1' is the section, if a email is a multi-part message in MIME format, you'll get plain text with 1.1
- $mailBody = imap_fetchbody($mbox, $mail->msgno, '1.1');
- // but if the email is not a multi-part message, you get the plain text in '1'
- if(trim($mailBody)=="") {
- $mailBody = imap_fetchbody($mbox, $mail->msgno, '1');
- }
- // just an example output to view it - this fit for me very nice
- echo 'dcm' . nl2br(htmlentities(quoted_printable_decode($mailBody))) . 'mcd<br>';
- }
- imap_close($mbox);
- die();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement