Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Reading from socket

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Reading from socket

Postby lazarantal » Mon Apr 01, 2013 11:17 pm

Hi,

I am trying to use the LIST command provided by Google for IMAP (as an extension).

If I connect to gmail imap from linux telnet and send this command from the console, I get the following result:

[#####@#### ~]$ telnet-ssl -z ssl imap.gmail.com 993
Trying 64.233.183.111...
Connected to gmail-imap.l.google.com.
Escape character is '^]'.
* OK Gimap ready for requests from 81.201.58.35 f4if1005730nfh.69
1 LIST "" "*"
* LIST (\HasNoChildren) "/" "INBOX"
* LIST (\Noselect \HasChildren) "/" "[Gmail]"
* LIST (\HasNoChildren \All) "/" "[Gmail]/All Mail"
* LIST (\HasNoChildren \Drafts) "/" "[Gmail]/Drafts"
* LIST (\HasNoChildren \Important) "/" "[Gmail]/Important"
* LIST (\HasNoChildren \Sent) "/" "[Gmail]/Sent Mail"
* LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
* LIST (\HasNoChildren \Flagged) "/" "[Gmail]/Starred"
* LIST (\HasNoChildren \Trash) "/" "[Gmail]/Trash"
1 OK Success


If I am sending this command from php, I am receiving only the last line:

* OK Gimap ready for requests from 212.51.93.33 e8if455192eeo.69 * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE C01 OK ###########@gmail.com ######## authenticated (Success) C02 OK Success


My php code is the following:

fwrite($fp, "C01 LOGIN username password\r\n");

while ($line = fgets($fp)) {
echo $line;
$line = preg_split('/\s+/', $line, 0, PREG_SPLIT_NO_EMPTY);
$code = $line[0];
if (strtoupper($code) == 'C01') {
break;
}
}

fwrite($fp, "C02 LIST '' '*'\r\n");

while ($line2 = fgets($fp))
{
echo $line2;
$line2 = preg_split('/\s+/', $line2, 0, PREG_SPLIT_NO_EMPTY);
$code = $line2[0];
if (strtoupper($code) == 'C02') {
break;
}
}

What am I doing wrong?

Regards,
Tony
lazarantal
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Mar 06, 2013 1:22 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.