Webklex / laravel-imap

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
https://www.php-imap.com
MIT License
629 stars 179 forks source link

Client doesn't connect to POP3 servers #402

Closed 91Abdullah closed 3 years ago

91Abdullah commented 3 years ago

Client doesn't work with POP3 clients and throws error (probably due to read-only access disabled from mail server). Apart from that client should support POP3 servers. Error is pasted below:

imap_open(): Couldn't open stream {0.0.0.0:110/pop3/novalidate-cert}. Read-only POP3 access not available (0)

To Reproduce Steps to reproduce the behavior:

$cm = new ClientManager();
        $client = $cm->make([
            'host' => '0.0.0.0',
            'port'          => 110,
            'encryption'    => false,
            'validate_cert' => false,
            'username'      => 'example@example.com',
            'password'      => 'example123',
            'protocol'      => 'pop3',
        ]);
        $client->connect();
        $folders = $client->getFolders();
        $client->disconnect();
        dd($folders);

Expected behavior Client should connect to POP3 server.

Solution After changing login function in LegacyProtocol.php (/webklex/php-imap/src/Connection/Protocols/LegacyProtocol.php) client connected successfully with POP3.

Error was due to passing option parameter in imap_open:

$this->stream = \imap_open(
                $this->getAddress(),
                $user,
                $password,
                ~~IMAP::OP_READONLY~~,
                $attempts = 3,
                ClientManager::get('options.open')
            );

The option should be configurable passed in the constructor etc.

Webklex commented 3 years ago

Hi @91Abdullah , many thanks for your detailed report.

Please feel free and welcome to push a pull request. I currently don't have a setup to test or play with pop3 :)

Best regards,

Webklex commented 3 years ago

Hi @91Abdullah , please update your webklex/php-imap dependency to the latest release (>2.7.0). This will hopefully solve the problem. If not, please head over to the webklex/php-imap repository and create a new issue.

Best regards,