mp82 Posted October 13, 2012 Share Posted October 13, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/269426-gmail-imap-via-php-socket/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.