Advertisement
tieudattai

ReadHotmail

May 11th, 2023
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. $username = $_REQUEST['u'];
  3. $password = $_REQUEST['p'];
  4. $server = '{imap-mail.outlook.com:993/ssl}';
  5. //$connection = imap_open($server, $username, $password);
  6.  
  7. //$msgnos = imap_search($connection, 'RECENT');
  8.  
  9.  
  10. $mbox = imap_open("{imap-mail.outlook.com:993/ssl}", $username, $password);
  11.  
  12. if(!$mbox)
  13. die('????');
  14.  
  15. // get information about the current mailbox (INBOX in this case)
  16. $mboxCheck = imap_check($mbox);
  17.  
  18. // get the total amount of messages
  19. $totalMessages = $mboxCheck->Nmsgs;
  20.  
  21. // select how many messages you want to see
  22. $showMessages = 5;
  23.  
  24. // get those messages
  25. $result = array_reverse(imap_fetch_overview($mbox,($totalMessages-$showMessages+1).":".$totalMessages));
  26.  
  27. // iterate trough those messages
  28. foreach ($result as $mail) {
  29. echo 'vkl';
  30. print_r($mail);
  31. echo 'lvk';
  32. echo '<br>';
  33. echo mb_decode_mimeheader($mail->subject);
  34. echo '<br>';
  35. // 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
  36. $mailBody = imap_fetchbody($mbox, $mail->msgno, '1.1');
  37.  
  38. // but if the email is not a multi-part message, you get the plain text in '1'
  39. if(trim($mailBody)=="") {
  40. $mailBody = imap_fetchbody($mbox, $mail->msgno, '1');
  41. }
  42.  
  43. // just an example output to view it - this fit for me very nice
  44. echo 'dcm' . nl2br(htmlentities(quoted_printable_decode($mailBody))) . 'mcd<br>';
  45. }
  46.  
  47. imap_close($mbox);
  48.  
  49.  
  50. die();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement