PHP code example of mvnaz / imapconnector

1. Go to this page and download the library: Download mvnaz/imapconnector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mvnaz / imapconnector example snippets


// This object contains all success and errors (You can use your own)
$responseContainer = \Mvnaz\ImapConnector\Containers\ResponseContainer::getInstance();

$connector = new \Mvnaz\ImapConnector\Connector($responseContainer);

// This object is for imap response parsing (You can use your own)
$parser = new \Mvnaz\ImapConnector\Parsers\Parser();

// Socks 5 proxy instance (You can also use HTTP proxy or your own implementation)
$socks5Proxy = new \Mvnaz\ImapConnector\Proxies\Socks5Proxy($responseContainer, "ip", 'port');

// Connecting to the proxy (if you skip this line script will connect to imap directly, without proxy)
$connector->connectToProxy($socks5Proxy);

// Here we get the stream which is via proxy (You can use this stream in your own order, i.e with your own commander)
$stream = $connector->connectToImap("imap_host", 'imap_port');

// Here we check if we was successfully connected to imap
if(is_resource($stream)) {

    // Here we create the commander and pass the stream
    $commander = new \Mvnaz\ImapConnector\Commander($stream, $parser, $responseContainer);

    // Lets login to imap
    if($commander->login("login", "password")){
        echo "Success!";
    }

}