New
Fork
Embed
View raw
Report
Check Gmail and Display Unread Messages - php
Close
Embed
You can embed this paste into a blog or website with this code:
<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/306" frameborder="0"></iframe>
Close
Add comment
Name
Comment
Validation
<?php
$mailbox
=
'{imap.gmail.com:993/ssl/novalidate-cert}INBOX'
;
$username
=
$_GET
[
'username'
]
;
$password
=
$_GET
[
'password'
]
;
$msg
=
$_GET
[
'msg'
]
;
$mbox
=
imap_open
(
$mailbox
,
$username
,
$password
)
;
$n
=
imap_num_msg
(
$mbox
)
;
//$imap_obj = imap_check($mbox);
//var_dump($imap_obj);
//echo "<br><hr>";
//echo $n;
//echo " total messages.";
//echo "<br><hr>";
//$body = imap_body($mbox, $msg);
$unread
=
0
;
for
(
$i
=
$n
;
$i
>=
$n
-
70
;
$i
--
)
{
$header
=
imap_headerinfo
(
$mbox
,
$i
)
;
if
(
$header
->
Unseen
==
"U"
)
{
$unread
++;
}
}
echo
"#"
.
$unread
;
?>
© 2011 Code Tidy