mail icon indicating copy to clipboard operation
mail copied to clipboard

Using Contacs groups in Bcc not possible

Open bjawede opened this issue 11 months ago • 10 comments

Steps to reproduce

  1. Open new Mail
  2. Got to An
  3. Fill will Email-Adress
  4. Go to Bcc
  5. Fill with contacts group
  6. push send button
  7. --> No E-Mail is sending to Bcc

Expected behavior

I have a problem with the mail app in Nextcloud: Sending emails via "Bcc" when entering a contact group from the Contacts app is not possible. When sending, the specified contact group is ignored and no one receives an email from it. The size of the contact group (number of email addresses it contains) is irrelevant. Contact groups with 2 or 87 entries, for example, are generally ignored. Even when saving the email as a draft, the contact group entry is not saved in "Bcc". When the draft email is opened, the address field is empty again. If email recipients are added individually in "Bcc", the email will be sent. But that is not what the inventor intended if you want to write to a lot of people. No problems when using contact groups in the "To" and "Cc" address fields. Contact groups can be used without any problems. Does anyone have the same problem and perhaps a solution so that sending via "Bcc" also works with contact groups? Reinstalling the Mail and Contacts app was not a solution.

Actual behavior

Sending emails via "Bcc" when entering a contact group from the Contacts app is not possible. When sending, the specified contact group is ignored and no one receives an email from it.

Image

Mail app version

4.1.2

Nextcloud version

30.0.5

Mailserver or service

No response

Operating system

Ubuntu Server 24.04.1 LTS

PHP engine version

PHP 8.3

Nextcloud memory caching

No response

Web server

Apache (supported)

Database

MariaDB

Additional info

  • Local Ubuntu server with classic Nextcloud installation
  • Hardware: PC, mainboard ASRock IMB-193, CPU i5-6600, 32GB RAM
  • Operating system: GNU/Linux 6.8.0-51, Ubuntu Server 24.04.1 LTS
  • Nextcloud version: 30.0.5
  • PHP version: 8.3.16
  • Database: MariaDB 10.11.8
  • Contacts app version: 6.1.3
  • Mail app version: 4.1.2
  • No abnormalities found in the logs

bjawede avatar Jan 29 '25 11:01 bjawede

Hello, we don't always experience the same phenomenon, but only sometimes. Unfortunately, I have not yet been able to reproduce the cases in which it occurs. In principle, we have the same configuration, except that the versions are up to date (NC 30). Kind regards, Jason

AdminMgl avatar Mar 27 '25 14:03 AdminMgl

i tried it several times, and i couldnt reproduce it. We must know the scenario that it fails. Does it fail for the same group, so when it works sometimes, its the same group?

Also, how was the group created, from the user management page or from the contact app?

GretaD avatar Apr 29 '25 13:04 GretaD

These are contact groups from the Contacts app. I have never been able to reproduce the error myself. But the error occurs with remarkable regularity (once or a few times a week). I then see a message in the nextcloud.log every 10 minutes. For example: "Could not send outbox message 1815: Eltern Klasse 11 (Contacts) has no members with email addresses" "file":"/var/www/nextcloud/apps/mail/lib/Service/GroupsIntegration.php","line":83 It almost seems to me as if the Mail app sometimes confuses user groups and contact groups at this point. The contact group “Eltern Klasse 11” has many contacts and therefore many email addresses. However, there is no user group called "Eltern Klasse 11", so it does not have any email addresses.

AdminMgl avatar May 02 '25 17:05 AdminMgl

thank you for the extra information, this is very helpful

GretaD avatar May 05 '25 12:05 GretaD

If it helps, I can provide more information. Please ask if you need specific data.

The contact groups are all from address books that no user has write access to, as they are generated by CardDav from the school management system. I always perform these synchronization runs manually after checking the data. This means that no “random” user changes can occur.

Strangely, this error only occurs occasionally. In other words, an email to a contact group is sent normally, and then an email to the same group gets stuck.

Although I have been searching for months, I have not been able to find a pattern or cause. However, one to a few emails get stuck in this way every week.

AdminMgl avatar May 09 '25 07:05 AdminMgl

Here is a very recent case: A teacher wants to inform the parents of his class about today's field trip yesterday afternoon. But the email does not leave the outbox.

The contact group has not been changed. Emails can be sent to them without any problems.

This affects all contact groups. Sometimes the emails are sent and sometimes they are not. It does not seem to depend on which field (TO, CC, BCC) the contact group is in. We have instructed our users to put the groups in BCC, but sometimes they seem to be (accidentally) in TO or CC.

Since I have tried to eliminate all errors on our end (e.g., in the data), I have attempted to get to the root of the problem.

The message comes from GroupsIntegration.php from the function ‘expand’ and when I look at it, I see three possible causes for this message:

  1. The contact group actually has no members with email addresses. This is definitely not true.
  2. The wrong service is being used (for whatever reason) and a user group with this name is being searched for. Since it does not exist, there would be no members with email addresses.
  3. There is another (side effect) error that I cannot see.

The log entry for this:

{
  "reqId": "lMzepBDsNflHQQexO4h8",
  "level": 2,
  "time": "2025-05-13T17:40:02+02:00",
  "remoteAddr": "",
  "user": "--",
  "app": "mail",
  "method": "",
  "url": "--",
  "message": "Could not send outbox message 2055: Eltern Klasse 5 (Contacts) has no members with email addresses",
  "userAgent": "--",
  "version": "30.0.10.1",
  "exception": {
    "Exception": "OCA\\Mail\\Exception\\ServiceException",
    "Message": "Eltern Klasse 5 (Contacts) has no members with email addresses",
    "Code": 0,
    "Trace": [
      {
        "function": "OCA\\Mail\\Service\\{closure}",
        "class": "OCA\\Mail\\Service\\GroupsIntegration",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/functions.php",
        "line": 19,
        "function": "array_map"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Service/GroupsIntegration.php",
        "line": 83,
        "function": "OCA\\Mail\\array_flat_map"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Service/TransmissionService.php",
        "line": 46,
        "function": "expand",
        "class": "OCA\\Mail\\Service\\GroupsIntegration",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php",
        "line": 76,
        "function": "getAddressList",
        "class": "OCA\\Mail\\Service\\TransmissionService",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/SendHandler.php",
        "line": 31,
        "function": "sendMessage",
        "class": "OCA\\Mail\\Service\\MailTransmission",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/AHandler.php",
        "line": 34,
        "function": "process",
        "class": "OCA\\Mail\\Send\\SendHandler",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/AntiAbuseHandler.php",
        "line": 54,
        "function": "processNext",
        "class": "OCA\\Mail\\Send\\AHandler",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/AHandler.php",
        "line": 34,
        "function": "process",
        "class": "OCA\\Mail\\Send\\AntiAbuseHandler",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/SentMailboxHandler.php",
        "line": 24,
        "function": "processNext",
        "class": "OCA\\Mail\\Send\\AHandler",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Send/Chain.php",
        "line": 54,
        "function": "process",
        "class": "OCA\\Mail\\Send\\SentMailboxHandler",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/Service/OutboxService.php",
        "line": 238,
        "function": "process",
        "class": "OCA\\Mail\\Send\\Chain",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/mail/lib/BackgroundJob/OutboxWorkerJob.php",
        "line": 30,
        "function": "flush",
        "class": "OCA\\Mail\\Service\\OutboxService",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OCA\\Mail\\BackgroundJob\\OutboxWorkerJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
        "line": 88,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
        "line": 75,
        "function": "start",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 162,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/apps/mail/lib/Service/GroupsIntegration.php",
    "Line": 94,
    "message": "Could not send outbox message {id}: Eltern Klasse 5 (Contacts) has no members with email addresses",
    "exception": {},
    "CustomMessage": "Could not send outbox message 2055: Eltern Klasse 5 (Contacts) has no members with email addresses"
  }
}

AdminMgl avatar May 14 '25 08:05 AdminMgl

Unfortunately, I haven't been able to reproduce the error intentionally.

On our development system (which works with a copy of the data from the production system), I get this message every 10 minutes in nextcloud.log. Unfortunately, the debug level didn't provide any more information.

What can I add to which PHP file to get further information?

Maybe we can troubleshoot the issue together.

AdminMgl avatar May 16 '25 08:05 AdminMgl

I tried to track down the problem with Xdebug.

It looks as if the system address book is the only address book loaded in nextcloud/lib/private/ContactsManager.php:35.

That's strange.

AdminMgl avatar May 29 '25 17:05 AdminMgl

I took another look at this today with Xdebug:

It looks to me as if only the system address book is loaded because there is no session with a user. And since the address books depend on the user, none can be loaded, at least not when the OutboxService is called by the cron job.

Accordingly, it could be that a contact group can be dissolved if the email is sent directly, but not if the email is first sent via cron job.

Could that be the case?

I'll try to set up a suitable test scenario.

AdminMgl avatar May 30 '25 12:05 AdminMgl

I can finally reproduce the error and have open an issue: https://github.com/nextcloud/mail/issues/11209

AdminMgl avatar May 30 '25 14:05 AdminMgl

In my case there was a problem with a specific mail address of one of the group members, e.g. a unicode character. Fixing the address fixed the problem :)

Chartman123 avatar Oct 28 '25 09:10 Chartman123