OutboxWorkerJob does not work with contact groups
Steps to reproduce
- Create a contact group with at least one contact with an email address.
- Create an email in the Mail app to this contact group (To, CC, or BCC), send it, and wait (at least 10 seconds).
- Create another email as before, send it, and log out immediately (and close the tab or browser).
Expected behavior
Both emails should have been delivered in both cases (without an error message).
Actual behavior
The first email is sent.
The second email is not sent. It remains in the outbox. Ten minutes later, the following entry will appear in the Nextcloud log: “Could not send outbox message 1603: aTest1 (Contacts) has no members with email addresses.”
Mail app version
5.1.1 and all older since at least about 6 month
Nextcloud version
31.0.5 and all older since at least about 6 month
Mailserver or service
no matter
Operating system
no matter
PHP engine version
PHP 8.3
Nextcloud memory caching
memcache.local
Web server
Nginx
Database
MariaDB
Additional info
I traced the problem with Xdebug until I found the cause: When attempting to open the address books, the user is queried from the session. There is no session and no user in the cron job, so ContactsManager does not return any contacts. A distinction must be made between whether the services are running within an active session with a user or within the cron job. In the second case, the user must be actively set so that their address books can be loaded.
Hi @AdminMgl,
Thank you very much 🙏
I can confirm that without a user session, just the system address book is available and the user's contact groups are unavailable.
Related code in server:
https://github.com/nextcloud/server/blob/35930a4331150d231be30fe05269ecfbd92d1f8d/apps/dav/lib/AppInfo/Application.php#L228-L235
Steps to reproduce:
- Create a contacts group in contacts
- Add Alice and Bob to the contacts group
- Write an email and select the contacts group as recipient
- Pick "Send later"
- Trigger OutboxWorkerJob manually (e.g. by resetting the send_at column for the local message