secit-pl / imap-bundle

Simple php-imap integration for Symfony
MIT License
71 stars 20 forks source link

Multiple connection not work #9

Closed Visioweb closed 2 years ago

Visioweb commented 4 years ago

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: "info@visioweb.it" password: "mypass1"

    infobenessere:
        mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
        username: "info@benessereevita.it"
        password: "mypass2"

    relishvisio:
        mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
        username: "relish@visioweb.it"
        password: "mypass3"

    airaldivisio:
        mailbox: "{ssl0.ovh.net:993/imap/ssl}INBOX"
        username: "airaldi@visioweb.it"
        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
ghost commented 3 years ago

Same here. Maybe someone will answer?

ghost commented 3 years ago

Easy solution: $isConnectable = $this->get('secit.imap')->testConnection('example_connection');

Just test the new connection first so the old one is resettet.

secit-pl commented 2 years ago

Hi I'm trying to reproduce this issue but from my side all looks ok.

Configuration:

imap:
    connections:
        test1:
            mailbox: "{domain.com:993/imap/ssl/novalidate-cert}INBOX"
            username: "USER1"
            password: "PASS1"

        test2:
            mailbox: "{domain.com:993/imap/ssl/novalidate-cert}INBOX"
            username: "USER2"
            password: "PASS2"
            attachments_dir: "%kernel.project_dir%/var/imap/attachments"
            server_encoding: "UTF-8"

        test3:
            mailbox: "{domain.com:993/imap/ssl/novalidate-cert}INBOX"
            username: "USER3"
            password: "PASS3"
            attachments_dir: "%kernel.project_dir%/var/imap/attachments"
            server_encoding: "UTF-8"

Test code:

<?php

namespace App\Command;

use SecIT\ImapBundle\Service\Imap;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
    name: 'imap:test',
)]
class ImapTestCommand extends Command
{
    private Imap $imap;

    public function __construct(Imap $imap)
    {
        parent::__construct();

        $this->imap = $imap;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        dump($this->imap->get('test1')->getMailboxInfo());
        dump($this->imap->get('test2')->getMailboxInfo());
        dump($this->imap->get('test3')->getMailboxInfo());

        return Command::SUCCESS;
    }
}

the output:

{#5759
  +"Unread": 0
  +"Deleted": 0
  +"Nmsgs": 0
  +"Size": 0
  +"Date": "Wed, 9 Mar 2022 07:39:44 +0100 (CET)"
  +"Driver": "imap"
  +"Mailbox": "{domain.com:993/imap/notls/ssl/novalidate-cert/user="USER1"}INBOX"
  +"Recent": 0
}
{#6549
  +"Unread": 0
  +"Deleted": 0
  +"Nmsgs": 0
  +"Size": 0
  +"Date": "Wed, 9 Mar 2022 07:39:44 +0100 (CET)"
  +"Driver": "imap"
  +"Mailbox": "{domain.com:993/imap/notls/ssl/novalidate-cert/user="USER2"}INBOX"
  +"Recent": 0
}
{#4811
  +"Unread": 0
  +"Deleted": 0
  +"Nmsgs": 0
  +"Size": 0
  +"Date": "Wed, 9 Mar 2022 07:39:45 +0100 (CET)"
  +"Driver": "imap"
  +"Mailbox": "{domain.com:993/imap/notls/ssl/novalidate-cert/user="USER3"}INBOX"
  +"Recent": 0
}

Please describe your: