PHPackages                             bartv2/imap-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. bartv2/imap-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

bartv2/imap-bundle
==================

Symfony integration for directorytree/imapengine.

1.0.0(3mo ago)01MITPHPPHP &gt;=8.1CI passing

Since Mar 18Pushed 3mo agoCompare

[ Source](https://github.com/bartv2/imap-bundle)[ Packagist](https://packagist.org/packages/bartv2/imap-bundle)[ RSS](/packages/bartv2-imap-bundle/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (2)Used By (0)

IMAP Engine integration bundle
------------------------------

[](#imap-engine-integration-bundle)

Simple [ImapEngine](https://imapengine.com/) integration for Symfony using `directorytree/imapengine`.

Compatibility matrix
--------------------

[](#compatibility-matrix)

Bundle versionMaintainedSymfony versionsMin. PHP version1.xYes6.4 to 8.x8.1.0Installation
------------

[](#installation)

#### 1. Composer

[](#1-composer)

From the command line run

```
composer require bartv2/imap-bundle
```

Configuration
-------------

[](#configuration)

To set up your mailbox configuration open the `config/packages/imap.yaml` and adjust its content.

Here is the example configuration:

```
imap:
    mailboxes:
        example:
            host: "imap.example.com"
            port: 993
            username: "email@example.com"
            password: "password"
            encryption: "ssl"
            validate_cert: false

        another:
            host: "imap.example.com"
            port: 143
            username: "username"
            password: "password"
            encryption: "starttls"

        full_config:
            host: "imap.example.com"
            port: 993
            timeout: 30
            debug: false
            username: "username"
            password: "password"
            encryption: "ssl"
            validate_cert: true
            authentication: "plain"
            proxy:
                socket: null
                username: null
                password: null
                request_fulluri: false
```

See [ImapEngine Configuration](https://imapengine.com/docs/usage/configuration) page for more examples.

### Security

[](#security)

It's good practice to do not set the sensitive data like mailbox, username and password directly in the config-files. You may have to [encode the values](https://symfony.com/doc/current/doctrine.html#configuring-the-database). [Configuration Based on Environment Variables](https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables)[Referencing Secrets in Configuration Files](https://symfony.com/doc/current/configuration/secrets.html#referencing-secrets-in-configuration-files)Better set them in `.env.local`, use Symfony Secrets or CI-Secrets.

```
imap:
    mailboxes:
        example:
            host: '%env(EXAMPLE_MAILBOX_HOST)%'
            port: '%env(int:EXAMPLE_MAILBOX_PORT)%'
            username: '%env(EXAMPLE_MAILBOX_USERNAME)%'
            password: '%env(EXAMPLE_MAILBOX_PASSWORD)%'
            encryption: '%env(EXAMPLE_MAILBOX_ENCRYPTION)%'
```

### Dump actual config:

[](#dump-actual-config)

```
php bin/console debug:config imap
```

### Validate if the mailboxes can connect correct

[](#validate-if-the-mailboxes-can-connect-correct)

```
php bin/console bartv2:imap:validate-mailboxes
```

Result:

```
+------------------+---------------------+---------------------------+--------------------+
| Mailbox       | Connect Result      | Mailbox                   | Username           |
+------------------+---------------------+---------------------------+--------------------+
| example          | SUCCESS             | imap.example.com:993      | user@mail.com      |
| example_WRONG    | FAILED: Reason..... | imap.example.com:993      | WRONG              |
+------------------+---------------------+---------------------------+--------------------+

```

This command can take some while if any connection failed. That is because of a long connection-timeout. If you use this in CI-Pipeline add the parameter `-q`. Password is not displayed for security reasons. You can set an array of mailboxes to validate.

```
php bin/console secit:imap:validate-mailboxes example example2

```

Usage
-----

[](#usage)

Let's say your config looks like this

```
imap:
    mailboxes:
        example:
            username: ...

        second:
            username: ...
```

You can get the mailbox inside a class by using service [autowiring](https://symfony.com/doc/current/service_container/autowiring.html) and using camelCased mailbox name + `Mailbox` as parameter name.

```
