PHP code example of dadadev / imap-bundle

1. Go to this page and download the library: Download dadadev/imap-bundle 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/ */

    

dadadev / imap-bundle example snippets


class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new DaDaDev\ImapBundle\ImapBundle(),
        ];

        ...
    }
}



namespace App\Controller;

use DaDaDev\ImapBundle\Service\Imap;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class IndexController extends AbstractController
{
    public function indexAction(Imap $imap)
    {
        $exampleConnection = $imap->get('example_connection');
        $anotherConnection = $imap->get('another_connection');

        ...
    }

    ...
}




namespace App\Controller;

use DaDaDev\ImapBundle\Service\Imap;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class IndexController extends Controller
{
    public function indexAction()
    {
        $exampleConnection = $this->get('dadadev.imap')->get('example_connection');
        $anotherConnection = $this->get('dadadev.imap')->get('another_connection');

        ...
    }

    ...
}


$exampleConnection = $this->get('dadadev.imap')->get('example_connection');
$exampleConnection->getMailboxInfo();

// testing with a boolean response
$isConnectable = $this->get('dadadev.imap')->testConnection('example_connection');
var_dump($isConnectable);

// testing with a full error message
try {
    $isConnectable = $this->get('dadadev.imap')->testConnection('example_connection', true);
} catch (\Exception $exception) {
    echo $exception->getMessage();
}