Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29767

Laravel Imap connect() slow | reuse?

$
0
0

I am using laravel-imap to connect to my email server and get all mailboxes and messages.

I noticed that the connect() method is slow, it takes 4-5 sec.:

$start = microtime(true);

$oClient = new Client([
    'host'          => env('MAIL_HOST_IN'),
    'port'          => env('MAIL_PORT_IN'),
    'encryption'    => env('MAIL_ENCRYPTION_IN'),
    'validate_cert' => true,
    'username'      => env('MAIL_USERNAME'),
    'password'      => env('MAIL_PASSWORD'),
    'protocol'      => 'imap'
]);

// Connect to the IMAP Server
$oClient->connect(); 

\Log::info('Connect: ' . strval(microtime(true) - $start));

Thats it, there is no additional code. I also use getFolders() and loop through them to get messages. I count/get unseen messages and do more operations, but they are all fast.

I am asking this, because if I login into my mailbox through the website, the performance is much better 1-2 sec. And the operation is the same, I get the mailboxes and a count on unseen messages. So why it is slow via script?

In case it simply is like that and I cant change it, what are some possible solutions? The only idea I have right now it to reuse the connection in multple functions, so at least I connect only once.


Viewing all articles
Browse latest Browse all 29767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>