Problem with bounces

Hello everyone, first post here, so first of all, hi!

I recently finished migrating a phplist 3.6.10 from centos8 to ubuntu 22.04 and everything is working fine… except for bounces. The server is running:
Exim 4.95 listening to localhost only
Apache server 2.4.54 with PHP-FMP 8.2.1
MariaDB 15.1
The bounces are configured to check an mbox file (/var/mail/mails)
The file has read access to everyone and doing:
sudo -u www-data cat /var/mail/mails
the file opens properly, but if I run this command (that I have set up in a cron job) I get an error:

/usr/local/bin/phplist -pprocessbounces
phpList - phpList version 3.6.10 (c) 2000-2023 phpList Ltd, https://www.phplist.com
phpList - Cannot open mailbox file Can’t open mailbox /var/mail/mails: no such mailbox
phpList - Download failed, exiting

Here’s the piece of config.php regarding the bounces configuration. I removed the comments and the bounce e-mail address just for clarity and safety:

define(‘PHPMAILERHOST’, ‘localhost’);
define(‘PHPMAILER_SECURE’,‘false’);
define(‘TEST’, 0);
$message_envelope = ‘REDACTED’;
$bounce_protocol = ‘mbox’;
define(‘MANUALLY_PROCESS_BOUNCES’, 1);
$bounce_mailbox = ‘/var/mail/mails’;
$bounce_mailbox_purge = 1;
$bounce_mailbox_purge_unprocessed = 1;
$bounce_unsubscribe_threshold = 50;

What I tried so far:
I made a symlink to the mail file at the lists folder and then pointed config.php there. Same result.
Changed the owner of the mails file (although the permissions are -rw-rw-rw- which means everyone can read and write it) with no luck either.
Changed define(‘MANUALLY_PROCESS_BOUNCES’, 1); to 0 just in case that could somehow be the problem. Again no luck.
I downloaded the mails file and opened it with an mbox viewer (just to be sure that the file format is correct). The file opened with no issues.

I ran out of ideas. Any help here would be very appreciated.

Thanks!

@eachenbach See this comment about using a full path to the mailbox PHP: imap_open - Manual

Hello @duncanc , thanks for answering my post.
I read the link and I’m a bit confused about the route where the file should be in this case.

The cron is run by root, so should the file be located inside root’s homedir (/root)?
If we are talking about www-data (the user running apache) then it’s home dir is /var/www, so I’m a bit confused where the file should be so it can be accessed correctly.

I did a bit of code reading and I understand that this is where the bounce gets processed inside processbounces.php in my case:

function processMbox($file)
{
set_time_limit(6000);

if (!TEST) {
    $link = imap_open($file, '', '', CL_EXPUNGE);
} else {
    $link = imap_open($file, '', '');
}
if (!$link) {
    outputProcessBounce($GLOBALS['I18N']->get('Cannot open mailbox file').' '.imap_last_error());

    return false;
}

return processMessages($link, 100000);

}

$link = imap_open($file, ‘’, ‘’, CL_EXPUNGE); ← when $file is expanded that’s where the path cannot be a full path starting from / or …/, right?

Thanks!

@eachenbach At that point in the code $file is $bounce_mailbox from the config.php file.

You might be able to create a link to the real mailbox in the home directory, so that $bounce_mailbox might be something like '~/mails' with mails being a link to /var/mail/mails

Thanks for the help @duncanc, I’m trying to figure out the home directory of which user, because I tried both root and www-data and in both cases I still get the same error message.

I’ll keep trying and see if I can find a solution.

Well, It seems to be working now.
What I did is make a link called mails to /var/www (www-data’s home folder) and then $bounce_mailbox = ‘mails’.
Then I moved the cron from root to www-data and it’s working now.

Thanks for the help!