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
https://forums.phpfreaks.com/topic/269426-gmail-imap-via-php-socket/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.