Simple php-imap integration for Symfony 2.8, 3.x and 4.x.

Overview

PHP-IMAP integration bundle

Simple php-imap integration for Symfony 4.x, 5.x and 6.x.

The version 1.5 and above are only compatible with Symfony 4+. Previous versions support was dropped. If you'd like to use it with Symfony 2.8 or 3.x you should use the version 1.4 which was the last compatible with Symfony 2.8 and 3.x.

Want to support this bundle?

Consider buying our MacOS app which allows you to customize your MacOS menu bar.

Infinite Menu Bar allows you to add to your menu bar custom elements. Want to have current IP (local or external), Macbook battery state, Bitcoin price or even custom contet from any HTTP URL or API? No problem! This app can do this and many more!

Infinite Menu Bar

Installation

1. Composer

From the command line run

$ composer require secit-pl/imap-bundle

If you're using Symfony Flex you're done and you can go to the configuration section otherwise you must manually register this bundle.

2. Register bundle

If you're not using Symfony Flex you must manually register this bundle in your AppKernel by adding the bundle declaration

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

        ...
    }
}

Configuration

Setup your mailbox configuration. If your are using symfony 2.8 or 3.x without Symfony Flex add your configuration in app/config/config.yml. If you're using Symfony 4 or Symfony 3.x with Flex open the config/packages/imap.yaml and adjust its content.

Here is the example configuration:

imap:
    connections:
        example_connection:
            mailbox: "{localhost:993/imap/ssl/novalidate-cert}INBOX"
            username: "[email protected]"
            password: "password"

        another_connection:
            mailbox: "{localhost:143}INBOX"
            username: "username"
            password: "password"
            attachments_dir: "%kernel.project_dir%/var/imap/attachments"
            server_encoding: "UTF-8"

        full_config_connection:
            mailbox: "{localhost:143}INBOX"
            username: "username"
            password: "password"
            attachments_dir: "%kernel.project_dir%/var/imap/attachments"
            create_attachments_dir_if_not_exists: true # default true
            created_attachments_dir_permissions: 777 # default 770
            server_encoding: "UTF-8"

If you're using Symfony to connect to a Microsoft 365 business environment, there's a good chance you'll want to connect to a shared mailbox. In that case you need to specify the parameters authuser and user. Where shared_account is the username without domain, like:

imap:
    connections:
        example_connection:
            mailbox: "{outlook.office365.com:993/imap/ssl/[email protected]/user=shared_account}Root/Folder"
            username: "[email protected]"
            password: "password"

Usage

With autowiring

In your controller:

<?php

namespace App\Controller;

use SecIT\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');

        ...
    }

    ...
}

With service container

In your controller:

<?php

namespace App\Controller;

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

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

        ...
    }

    ...
}

From this point you can use any of the methods provided by the php-imap library. For example

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

To quickly test the connection to the server you can use the testConnection() method

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

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

Be aware that this will disconnect your current connection and create a new one on success. In most cases this is not a problem.

Comments
  • Improve configuration definition

    Improve configuration definition

    This allows you to use the new php based configuration without hassle:

    return static function(ImapConfig $imap): void
    {
    	$imap->connection('some_connection')
    	     ->mailbox('a_mailbox');
    	$imap->connection('second_connection')
    	     ->mailbox('another_mailbox');
    };
    
    opened by bobvandevijver 4
  • Problems in my Docker Environment

    Problems in my Docker Environment

    Hey, after installing it on my Symfony Docker environment I get the following Error:

    Attempted to call function "imap_search" from namespace "PhpImap"

    What can I do to solve this?

    opened by tomwuell 3
  • Multiple connection not work

    Multiple connection not work

    Hi I installed his library on symfony 5, created the imap.yaml file and inside I entered the various emails addresses with relative accesses, but if I go to recall them in the controller I always find the results of the first email why? imap: connections: infovisioweb: mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX" username: "[email protected]" password: "mypass1"

        infobenessere:
            mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
            username: "[email protected]"
            password: "mypass2"
            
        relishvisio:
            mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
            username: "[email protected]"
            password: "mypass3"
            
        airaldivisio:
            mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
            username: "[email protected]"
            password: "mypass4"
    

    in DefaultController.php: $infovisioweb = $imap->get('infovisioweb')->getMailboxInfo(); dump($infovisioweb); // result is 5107 = exactly $infobenesserevita = $imap->get('infobenessere')->getMailboxInfo(); dump($infobenesserevita); // result is 5107 = not exactly but result is 76

        $relishvisioweb = $imap->get('relishvisio')->getMailboxInfo();
        dump($relishvisioweb);
       // result is 5107  = not exactly but result is 120
        
        $airaldivisioweb = $imap->get('airaldivisio')->getMailboxInfo();
        dump($airaldivisioweb);
        // result is 5107  = not exactly but result is 759
    
    opened by Visioweb 3
  • oAuth authentication support

    oAuth authentication support

    Hello @secit-pl,

    I installed imap-bundle on my Symfony 5.4 project, but cannot authenticate on Office 365 to retrieve emails with IMAP.

    The reason is probably the deprecation of basic authentication by Microsoft : https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online?source=recommendations

    Is there a way to use an oAuth access token to authenticate ? If not, is it going to be supported in the future ?

    Thanks you !

    opened by pbories 2
  • feat: drop support of php < 7, update readme

    feat: drop support of php < 7, update readme

    #23

    WIP: I need to test it first. Of course i would be glad if someone can help.

    Symfony dependencies are at 4.4 as the latest supportet LTS from Symfony. < 4.4 are not maintained by symfony itself.

    I guess this does not need to be nullable. Or is there a reason? protected function checkAttachmentsDir(?string $directoryPath

    opened by Chris53897 2
  • New Major version with PHP >= 8.0 and Symfony >= 5.4

    New Major version with PHP >= 8.0 and Symfony >= 5.4

    @secit-pl Are you open for a PR for a new major version with PHP >= 8.0 and Symfony >= 5.4, strong types and new language level features? Composer handles the old version, so there is no problem with existing users of this repo.

    I can start the PR after I have your go.

    opened by Chris53897 2
  • attachment support

    attachment support

    i see my attachment

    IncomingMailAttachment {#563 ▼ +id: "14221071831878934793" +contentId: "auto_cid_2817556830" +name: "cpanel-logo-tiny.png" +filePath: null +disposition: "attachment" }

    how i can download it ?

    opened by grekpg 2
  • Add `extra.branch-alias` config at `composer.json` in order to allow installs from dev versions while respecting SemVer

    Add `extra.branch-alias` config at `composer.json` in order to allow installs from dev versions while respecting SemVer

    |Q |A | |--- |--- | |Branch |master| |Bug fix? |no | |New feature? |no | |BC breaks? |no | |Deprecations?|no | |Tests pass? |yes | |Fixed tickets|n/a | |License |MIT | |Doc PR |n/a |

    opened by phansys 2
  • Update Repo => About (Add Symfony 5 and 6)

    Update Repo => About (Add Symfony 5 and 6)

    Text that is displeayed in the upper, right corner of the github-page.

    Actual: Simple php-imap integration for Symfony 2.8, 3.x and 4.x.

    Suggestion: Simple php-imap integration for Symfony 2-6

    opened by Chris53897 1
  • Minor symfony 6.1 deprecation

    Minor symfony 6.1 deprecation

    After upgrading to symfony 6.1, I'm getting this new deprecation:

    Method "Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder()" might add "TreeBuilder" as a native return type declaration in the future. Do the same in implementation "SecIT\ImapBundle\DependencyInjection\Configuration" now to avoid errors or add an explicit @return annotation to suppress this message.

    Seems like an easy fix...

    opened by ehymel 1
  • directory permissions wrong?

    directory permissions wrong?

    created_attachments_dir_permissions is declared as an integer node in configuration https://github.com/secit-pl/imap-bundle/blob/master/DependencyInjection/Configuration.php#L53

    When default value is 770 , the variable $directoryPermissions in https://github.com/secit-pl/imap-bundle/blob/master/Service/Imap.php#L119 has the integer value 770. And when we decoct(770) we have "1402" as permissions and creating the folder with wrong permissions.

    Why dont pass the created_attachments_dir_permissions as scalarNode ?

    php version 7.2.24 secit-pl/imap-bundle version 1.5.0

    opened by akmez 1
Owner
null
Tabler.io bundle for Symfony - a backend/admin theme for easy integration

Tabler Bundle for Symfony This repository contains a Symfony bundle, integrating the fantastic Tabler.io HTML Template into your Symfony project. It s

Kevin Papst 22 Jan 2, 2023
Sanitize untrustworthy HTML user input (Symfony integration for https://github.com/tgalopin/html-sanitizer)

html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing you to store it and display it safely. It has sensible defaults to provide a great developer experience while still being entierely configurable.

Titouan Galopin 86 Oct 5, 2022
AccessibleBundle provides an Accessible integration for your Symfony projects

AccessibleBundle AccessibleBundle provides an Accessible integration for your Symfony projects. This will allow you to define your class behavior usin

Antares Tupin 13 Apr 2, 2022
MeteionBundle is the Symfony integration of the Meteion library.

MeteionBundle MeteionBundle is a Symfony integration of the Meteion library. Key features Auto-configuration Commands Services Entities Installation c

Hiero 1 May 3, 2022
Symfony Framework Integration for HTTPlug

HTTPlug Bundle Symfony integration for HTTPlug. Installation To install the bundle with Symfony Flex, use the recipe: $ composer require php-http/http

The PHP HTTP group 369 Jan 3, 2023
Integration with your Symfony app & Stimulus!

StimulusBundle: Symfony integration with Stimulus! This bundle adds integration between Symfony, Stimulus and Symfony UX: A) Twig stimulus_* functions

Symfony 12 Jun 12, 2023
Dockerise Symfony Application (Symfony 6 + Clean Architecture+ DDD+ CQRS + Docker + Xdebug + PHPUnit + Doctrine ORM + JWT Auth + Static analysis)

Symfony Dockerise Symfony Application Install Docker Install Docker Compose Docker PHP & Nginx Create Symfony Application Debugging Install Xdebug Con

null 48 Jan 5, 2023
Simple yet powerful, PSR-compliant, Symfony-driven PHP Blog engine.

brodaty-blog ✒️ Simple Blog Engine based on pure Markdown files. ?? Works without database, caches HTML templates from Markdown files. ?? Fast and ext

Sebastian 3 Nov 15, 2022
Simple Symfony currency exchange demo application (CLI)

Symfony currency exchange demo Keynotes Using a small Symfony installation as possible Using SQLite database for simplicity but with price of some cav

Vladimir Martsul 9 Oct 21, 2022
Simple HTTP smoke testing for your Symfony application

Shopsys HTTP Smoke Testing This package enables you to do simple HTTP smoke testing of your Symfony application. Basically, it generates a HTTP reques

Shopsys 65 Feb 3, 2022
Implement a "Where's Wally" (or Waldo/Charlie) Captcha in a simple Symfony Project

Where's Wally ? Nowadays, we are often confronted with "Captcha". These tests to know if we are robots or not. They are all very boring and not very f

rherault 3 Oct 7, 2022
Enhance product data quality and streamline content creation with the Pimcore and ChatGPT integration.

chatgpt-pimcore Enhance product data quality and streamline content creation with the Pimcore and ChatGPT integration. Overview The integration of Pim

Pravin chaudhary 6 Jun 5, 2023
Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitweb, Cgit, Subversion, Mercurial and more

Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitweb, Cgit, Subversion, Mercurial and more

MantisBT Community Plugins 175 Sep 3, 2022
FULL, FREE and SUPPORTED integration with MailChimp Email Marketing for Magento 2.

MageMonkey has been deprecated, please use MailChimp for Magento instead MailChimp official Magento extension Support MageMonkey, Subscribe for a free

Ebizmarts 47 May 23, 2022
Vite integration for WordPress plugins and themes development.

Vite for WordPress Vite integration for WordPress plugins and themes development. Usage Let's assume we have this plugin files structure: my-plugin/ ├

Dzikri Aziz 48 Jan 2, 2023
A bot written in PHP which attempts to link IRC with SQL database, allowing for integration between platforms

Valeyard IRC-SQL-GateWay A bot written in PHP which attempts to link IRC with SQL database, allowing for integration between platforms. This bot is mo

Valerie Pond 10 Oct 6, 2022
the repository uses some of the code from php-meminfo to simplify integration

the repository uses some of the code from php-meminfo to simplify integration

Dmitriy Bulgar 1 Nov 18, 2021
QuickBooks Integration for PHP

QuickBooks PHP DevKit QuickBooks integration support for PHP 5.x+ The package you've downloaded contains code and documentation for connecting various

Keith Palmer 443 Dec 19, 2022
Laravel Integration for Switchover PHP SDK. Feature Toggle Management made easy.

Switchover Laravel Integration Switchover Switchover is a Software-As-A-Service for managing feature toggles (aka switches, flags or feature flips) in

Switchover 6 Nov 6, 2022