caponica/imap-bundle

Symfony2 service wrapper for PhpImap

Installs: 1 721

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master 2016-11-05 18:29 UTC

This package is auto-updated.

Last update: 2021-11-15 03:57:36 UTC


README

PhpImap integration via a Symfony service.

Installation

Install using composer by adding the following in the require section of your composer.json file:

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

Register the bundle in your kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Caponica\ImapBundle\CaponicaImapBundle(),
    );
}

Configuration

The bundle does not add a service to your project by default. To add the service, you will need to define the parameters and then the service itself.

# app/config/parameters.yml
your_imap_config:
    imapPath:           '{imap.gmail.com:993/imap/ssl}INBOX'
    username:           you@gmail.com
    password:           your_password
    directory:          /path/to/folder
# services.yml
    caponica_imap_box:
        class:          Caponica\ImapBundle\Service\CaponicaImap
        calls:
            - [ setConfig, [ %your_imap_config_box% ]]

Usage

To access the service, just reference it by the service name you defined above. E.g., from a controller:

$caponicaImap = $this->container->get('caponica_imap_box');
$mailbox = $this->caponicaImap->getImapMailbox();
$mailsIds = $mailbox->sortMails(SORTDATE);