/** * Opens a POP3 Connection to a given server, and returns a GroupsPopClient object as a live session. * @param string $strServerUri * @param integer $intServerPort * @param string $strUsername * @param string $strPassword * @return GroupsPopClient */ public static function CreateClient($strServerUri, $intServerPort, $strUsername, $strPassword) { $objClient = new GroupsPopClient(); $objClient->objSocket = @fsockopen($strServerUri, $intServerPort); if (!$objClient->objSocket) { return null; } $objClient->ReceiveResponse('Initial Handshake'); $objClient->SendCommand(sprintf('USER %s', $strUsername)); $objClient->ReceiveResponse('USER Specification'); $objClient->SendCommand(sprintf('PASS %s', $strPassword)); $objClient->ReceiveResponse('PASS Specification'); $objClient->SendCommand('STAT'); $strStat = $objClient->ReceiveResponse('STAT Request'); $strStatTokens = explode(' ', $strStat); $objClient->intMessageCount = $strStatTokens[0]; return $objClient; }