Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
<?php

$stuff = fsockopen('ssl://imap.gmail.com',993);
$reply = fgets($stuff,4096);
echo 'connection: '.$reply.'<br/>';

$request = fputs($stuff,"a1 LOGIN ozgununlu91@gmail.com password\r\n");
$receive = fgets($stuff, 4096);

echo 'login: '.$receive.'<br/>';
$request = fputs($stuff,"a2 LIST '' '*'\r\n");
$response= fgets($stuff, 4096);
echo $response . "<br />";

$request = fputs($stuff,"a3 EXAMINE INBOX\r\n");
$response = '';
$end_of_response = false;
while(!$end_of_response){
$response.= fgets($stuff, 1024);
if(preg_match("/a3 (OK|NO|BAD)/", $response, $responsecode))
            $end_of_response = true;
    
}
print_r( $response);
echo "<br />";
$request = fputs($stuff, "a4 FETCH 2 BODY[]\r\n");

$response = fgets($stuff, 4024);
print_r( $response) ;
echo "<br />";

?>


Output:
 connection: * OK Gimap ready for requests from 83.66.211.216 k49if17516237eew.167 
login: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH 
a1 OK [email removed]@gmail.com Ozgun Unlu authenticated (Success) 
a2 OK Success * FLAGS (\Answered \Flagged \Draft \Deleted \Seen) * OK [PERMANENTFLAGS ()] Flags permitted. * OK [UIDVALIDITY 1] UIDs valid. * 63 EXISTS * 0 RECENT * OK [UIDNEXT 135] Predicted next UID. * OK [HIGHESTMODSEQ 25579] a3 OK [READ-ONLY] INBOX selected. (Success) 
* 2 FETCH (BODY[] {7131}



How can i read all gmails mail without imap functions?
Posted
Updated 28-Dec-13 14:19pm
v3
Comments
Mohibur Rashid 29-Dec-13 5:54am    
You better develop pop client. That would be easier

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900