Fetch/Read Mails Using Laminas

Has anyone had experience setting up/configuring mail system (reading mails) using Laminas framework on Linux?

My system info: CentOS 8, PHP 7.4.27, Elgg 4.0.0

I have mail system (postfix and dovecot) on my server to store enqueued notification messages. I want to fetch/read those messages. Below are what I have been trying but not working:

1. IMAP

$mail = new Laminas\Mail\Storage\Imap([

   'host' => 'localhost',

   'username' => 'name_of_mail_account',

   'password' => 'password_of_mail_account',

   'port' => 143

]);

$messages = $mail->getMessages( );

$messages are empty or have 0 message

 

2. Maildir

$mail = new \Laminas\Mail\Storage\Maildir([

   'dirname' => '/home/mail_owner_account/mail/.imap/INBOX'

]);

$messages = $mail->getMessages( );

error_log('Message count: ' . $message);

It does not even get to the error_log( ) line

 

Advice and suggestions would be very much appreciated!

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking