Jump to content

Gmail Imap Via Php Socket


mp82

Recommended Posts

Hi,

 

I'm trying to access my Gmail account by a socket connection (secure imap is closed by my provider).

 

 

Currently I'm at this coding state (not very far...):

////////////////////////////////////////////

// Open a socket

if (!($fp = fsockopen('ssl://imap.gmail.com', 993, $errno, $errstr, 15))) die("Could not connect to host");

 

// Set timout to 1 second

if (!stream_set_timeout($fp, 1)) die("Could not set timeout");

 

// Fetch first line of response and echo it

echo fgets($fp);

 

// Send data to server

echo "Writing data...";

fwrite($fp, "C01 CAPABILITY\r\n");

echo " Done\r\n";

 

// Keep fetching lines until response code is correct

while ($line = fgets($fp)) {

echo $line;

$line = preg_split('/\s+/', $line, 0, PREG_SPLIT_NO_EMPTY);

$code = $line[0];

if (strtoupper($code) == 'C01') {

break;

}

}

 

echo "I've finished!";

 

fclose($fp);

////////////////////////////////////////////

 

Output er følgende:

* OK Gimap ready for requests from 94.231.108.221 g8if1416270lbr.32 Writing data... Done * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 C01 OK Thats all she wrote! g8if1416270lbr.32 I've finished!

 

 

But how do I get IMAP working, hope somebody has some examples / ideas :)

 

 

/ Morten

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.