Guest User

Untitled

a guest
Oct 22nd, 2017
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. $hostname='{imap.gmail.com:993/imap/ssl}INBOX';
  2. $username = 'mygmail@gmail.com';
  3. $password = 'mypass';
  4.  
  5. /* try to connect */
  6. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Tiriyo: ' . imap_last_error());
  7. $MB = imap_search($inbox,'UNSEEN');
  8. $xcount($MB);
  9. echo $x;
  10.  
  11. // https://support.google.com/mail/answer/7126229 [2017-10-22]
  12. define('URL', 'imaps://imap.gmail.com');
  13. define('PORT', 993);
  14. define('USER', 'your.user@gmail.com');
  15. define('PASS', 'your_Secret_Password');
  16.  
  17. if ($ch = curl_init()) {
  18. curl_setopt($ch, CURLOPT_URL, URL);
  19. curl_setopt($ch, CURLOPT_PORT, PORT);
  20.  
  21. curl_setopt($ch, CURLOPT_USE_SSL, CURLUSESSL_ALL);
  22.  
  23. curl_setopt($ch, CURLOPT_USERNAME, USER);
  24. curl_setopt($ch, CURLOPT_PASSWORD, PASS);
  25.  
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  27. curl_setopt($ch, CURLOPT_HEADER, 0);
  28.  
  29. // set IMAP command
  30. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'STATUS INBOX (MESSAGES UNSEEN)');
  31.  
  32. $res = curl_exec($ch);
  33. if (curl_errno($ch)) {
  34. echo 'CURL ERROR: ' . curl_error($ch);
  35. } else {
  36. echo trim($res);
  37. }
  38. echo PHP_EOL;
  39.  
  40. curl_close($ch);
  41. } else {
  42. die('Curl initialization failed.');
  43. }
  44.  
  45. * STATUS "INBOX" (MESSAGES 2 UNSEEN 1)
Add Comment
Please, Sign In to add comment