Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $hostname='{imap.gmail.com:993/imap/ssl}INBOX';
- $username = 'mygmail@gmail.com';
- $password = 'mypass';
- /* try to connect */
- $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Tiriyo: ' . imap_last_error());
- $MB = imap_search($inbox,'UNSEEN');
- $xcount($MB);
- echo $x;
- // https://support.google.com/mail/answer/7126229 [2017-10-22]
- define('URL', 'imaps://imap.gmail.com');
- define('PORT', 993);
- define('USER', 'your.user@gmail.com');
- define('PASS', 'your_Secret_Password');
- if ($ch = curl_init()) {
- curl_setopt($ch, CURLOPT_URL, URL);
- curl_setopt($ch, CURLOPT_PORT, PORT);
- curl_setopt($ch, CURLOPT_USE_SSL, CURLUSESSL_ALL);
- curl_setopt($ch, CURLOPT_USERNAME, USER);
- curl_setopt($ch, CURLOPT_PASSWORD, PASS);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- // set IMAP command
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'STATUS INBOX (MESSAGES UNSEEN)');
- $res = curl_exec($ch);
- if (curl_errno($ch)) {
- echo 'CURL ERROR: ' . curl_error($ch);
- } else {
- echo trim($res);
- }
- echo PHP_EOL;
- curl_close($ch);
- } else {
- die('Curl initialization failed.');
- }
- * STATUS "INBOX" (MESSAGES 2 UNSEEN 1)
Add Comment
Please, Sign In to add comment