<commit_before>ImapBundle
==============

This bundle provides a functionality to work with email servers through IMAP protocol.

Dependencies
------------

"zendframework/zend-mail": "2.1.*"

Notes: We cannot use more recent version of zend-mail because besimple/soap-bundle uses it as well and requires 2.1.* version.


Installation
------------

### Step 1) Get the bundle and the library

Add on composer.json (see http://getcomposer.org/)

    "require" :  {
        // ...
        "oro/imap-bundle": "dev-master",
    }

### Step 2) Register the bundle

To start using the bundle, register it in your Kernel:

``` php
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Oro\Bundle\ImapBundle\OroImapBundle(),
    );
    // ...
}
```

Usage
-----

``` php
<?php
    // Accessing IMAP connector factory
    /** @var $factory \Oro\Bundle\ImapBundle\Connector\ImapConnectorFactory */
    $factory = $this->get('oro_imap.connector.factory');

    // Creating IMAP connector for the ORO user
    /** @var $imap \Oro\Bundle\ImapBundle\Connector\ImapConnector */
    $imapConnector = $factory->createUserImapConnector($userId);

    // Creating the search query builder
    /** @var $queryBuilder \Oro\Bundle\ImapBundle\Connector\Search\SearchQueryBuilder */
    $queryBuilder = $imapConnector->getSearchQueryBuilder();

    // Building a search query
    $query = $queryBuilder
        ->from('<EMAIL>')
        ->subject('notification')
        ->get();

    // Request an IMAP server for find emails
    $emails = $imapConnector->findItems('INBOX', $query);
```
<commit_msg>CRM-423: Inbox synchronization via IMAP<commit_after>ImapBundle
==============

This bundle provides a functionality to work with email servers through IMAP protocol.

Dependencies
------------

"zendframework/zend-mail": "2.1.*"

Notes: We cannot use more recent version of zend-mail because besimple/soap-bundle uses it as well and requires 2.1.* version.


Installation
------------

### Step 1) Get the bundle and the library

Add on composer.json (see http://getcomposer.org/)

    "require" :  {
        // ...
        "oro/imap-bundle": "dev-master",
    }

### Step 2) Register the bundle

To start using the bundle, register it in your Kernel:

``` php
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Oro\Bundle\ImapBundle\OroImapBundle(),
    );
    // ...
}
```

Usage
-----

``` php
<?php
    // Preparing connection config
    $imapConfig = new ImapConfig('imap.gmail.com', 993, 'ssl', 'user', 'pwd');

    // Accessing IMAP connector factory
    /** @var $factory \Oro\Bundle\ImapBundle\Connector\ImapConnectorFactory */
    $factory = $this->get('oro_imap.connector.factory');

    // Creating IMAP connector for the ORO user
    /** @var $imap \Oro\Bundle\ImapBundle\Connector\ImapConnector */
    $imapConnector = $factory->createImapConnector($imapConfig);

    // Creating IMAP manager
    $imapManager = new ImapEmailManager($imapConnector);

    // Creating the search query builder
    /** @var $queryBuilder \Oro\Bundle\ImapBundle\Connector\Search\SearchQueryBuilder */
    $queryBuilder = $imapManager->getSearchQueryBuilder();

    // Building a search query
    $query = $queryBuilder
        ->from('<EMAIL>')
        ->subject('notification')
        ->get();

    // Request an IMAP server for find emails
    $imapManager->selectFolder('INBOX');
    $emails = $imapManager->findItems($query);
```

Synchronization with IMAP servers
---------------------------------
Email synchronization functionality is implemented in the following classes:

 - ImapEmailSynchronizer
 - ImapEmailSynchronizationProcessor
 - EmailSyncCommand

{'fraction_non_alphanumeric': 0.15624168219323928, 'fraction_numerical': 0.004791056694170881, 'mean_word_length': 2.8504098360655736, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2746338', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1107, 'n_words': 300}