# Notification emails not being sent for Chat as per user preference

**URL:** https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556
**Category:** Bug
**Tags:** chat
**Created:** [November 6, 2022, 3:40pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556 "2022-11-06T15:40:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 6, 2022, 3:40pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/1 "2022-11-06T15:40:27Z")

</div>

Is there a way to force update the Preference of all users in a chat channel to receive email messages for chat?

I would like users to default to receiving emails.

Thank you.

---

<div class="post-metadata">

### Author: ![glimfeather](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/glimfeather/32/257582_2.png) [@glimfeather](https://meta.discourse.org/u/glimfeather)
#### Post date: [November 6, 2022, 3:43pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/2 "2022-11-06T15:43:44Z")

</div>

Why would you do that? Surely the user’s preferences are what _ **they** _ want. When I sign up for a new DIscourse instance the very first thing I do is go to my profile and change the email perferences to Never. I would be royal annoyed to find that someone had decided that they knew better than me about how I wished to interact with Discourse. Indeed if an admin did this to me I would consider it spamming!

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 6, 2022, 4:17pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/3 "2022-11-06T16:17:33Z")

</div>

Yes, it is not for overriding what the user selects.

However, it would make sense to have initial defaults. It appears that no emails are going out currently, when we enabled the chat functionality.

In our kind of forum, people would not go in to set preferences and expect to be notified adequately.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 6, 2022, 5:57pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/4 "2022-11-06T17:57:09Z")

</div>

I’ve just checked my test site, and I believe the default for chat email notifications is ‘only when away’ (with the only alternative being ‘never’).

 ![chat email preference](https://global.discourse-cdn.com/meta/original/4X/a/c/5/ac51557d0b83d2544eca91202327ce71272b7ddb.jpeg)

I think there is a case to allow for a default to be added to the User Preference admin settings, though probably for the inverse of what you’re suggesting. 🙂 This would work like the other defaults, in that it would only change the preference for users who had yet to select one manually.

I’ve slipped this over to #Contribute > UX for consideration. 👍

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 6, 2022, 6:23pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/5 "2022-11-06T18:23:21Z")

</div>

Thanks. But shouldn’t the default ‘Only when away’ pump out emails to everyone who hasn’t been on the site lately?

I had 300+ members on the general chat channel and only 2 messages went out.  
Needless to say, most of the 300 weren’t on the site in the 15 min window.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 6, 2022, 7:13pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/6 "2022-11-06T19:13:19Z")

</div>

You don’t get notifications for every chat message, only those where you’ve been mentioned (either your own @mention, `@here` and `@all`), so that may explain it?

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 6, 2022, 7:17pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/7 "2022-11-06T19:17:09Z")

</div>

Sorry I may not have clarified I used @ all (space added just here) but it didn’t work.

P.S. I am actually wondering why you are not added to the chit chat on my site as a recently active member. 😀

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 6, 2022, 7:52pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/8 "2022-11-06T19:52:51Z")

</div>

> [@Chandra](#):
>
> P.S. I am actually wondering why you are not added to the chit chat on my site as a recently active member. 😀

Ah, I’m afraid I deleted my test account on your site after I finished testing the post-voting comments. 🙂

I’ve had a quick play on seeing if there are any quirks about when a chat user gets included in `@all`, but (from my very brief look) it seemed to be everyone in the channel list. You could pick a couple of users who didn’t get the email and check to see if they got the notification, as well as their chat email preference to see if they’re as they should be?

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 7, 2022, 6:17am UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/9 "2022-11-07T06:17:05Z")

</div>

So here is my test:

**1. Chat channel settings to notify for everything (though I think it does not affect emails).**

 ![channel-setting](https://global.discourse-cdn.com/meta/original/4X/e/d/4/ed4ed18e1ba26f127c89078cc399cd9881c7e015.png)

**2. I picked a member from the 313 in the channel and here are the standard user prefs - ‘Email only when away’.  
Chat message with @ all created many hours back has sent notifications as seen here, but no emails.**

 ![chat-pref](https://global.discourse-cdn.com/meta/original/4X/2/f/a/2fa6e7ad59c204e2cbdf4954aee72a33389e6a32.png)

**3. No emails sent except for 2 members. Both are admins/mods and both used chat before - not sure if that is the differentiator.**

 ![2-emails-of-313-expected](https://global.discourse-cdn.com/meta/original/4X/6/5/0/65078df0a8ecec3f16b3f0281f5124d8d54b8318.png)

**4. On a separate note, it looks like Admin can’t see user’s chat preferences.**

 ![no-chat-pref-shown-to-admin](https://global.discourse-cdn.com/meta/original/4X/1/5/e/15e42959f8574b315374e08159e1b059ae0e92bc.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 7, 2022, 7:46am UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/10 "2022-11-07T07:46:49Z")

</div>

I’ve been exploring it a bit further this morning, and mine seem to be working okay. 🤔

I have 6 test users, all auto-enrolled members of the ~general channel. One is an admin, and one is a brand new TL0 user who has never opened the chat channel (or chat). None of them have logged in since yesterday (apart from the new test\_six user, though I made sure they had at least 15 minutes of ‘downtime’ prior to testing).

Pinging the ~general channel with `@all` sent them all a notification. Moments later 6 `chat_summary` emails were sent out to their respective test email addresses.

I’m not sure what else to check. I’ve had a dig around in the code, but my code-deciphering skills aren’t great. 🙂 I’ll have another think.

* * *

> [@Chandra](#):
>
> 1. On a separate note, it looks like Admin can’t see user’s chat preferences.

Thanks for mentioning that. 👍 I’ve raised it with the Team. 🙂

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 7, 2022, 6:29pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/11 "2022-11-07T18:29:20Z")

</div>

Thanks.  
Without having much expertise myself, users\_with\_unprocessed\_unread\_mentions in lib/chat\_mailer.rb does not seem to be pulling all the users to be emailed?

Would someone have a way to validate this…

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 8, 2022, 4:52pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/12 "2022-11-08T16:52:44Z")

</div>

@JammyDodger  
Updated title to reflect the actual issue.  
Any other tests you can suggest please?  
Should I tag this a bug or would you see any other tests to recreate?

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [November 8, 2022, 6:28pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/13 "2022-11-08T18:28:10Z")

</div>

I don’t think we have a clear reproduction yet.

My understanding is that @JammyDodger is trying to reproduce this issue based on your report, but has so far been unsuccessful.

A few notes:

> [@Chandra](#):
>
> Chat channel settings to notify for everything (though I think it does not affect emails).

To clarify, this is not a channel-wide setting, but a user preference _for that channel_. But what you’re showing are the defaults, so I’d suspect that most of the 313 members have it set that way.

> [@Chandra](#):
>
> I picked a member from the 313 in the channel and here are the standard user prefs - ‘Email only when away’.  
> Chat message with @ all created many hours back has sent notifications as seen here, but no emails.

Are you sure they were away? If they were on the site, then the notification will not send an email.

> [@Chandra](#):
>
> No emails sent except for 2 members. Both are admins/mods and both used chat before - not sure if that is the differentiator.

OK, that’s pretty strong evidence that _something_ isn’t working as expected here. I would have guessed that more than 2 out of 313 people would be away. Is is possible that they were all on the site at that time?

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 8, 2022, 7:13pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/15 "2022-11-08T19:13:22Z")

</div>

> [@mcwumbly](#):
>
> > [@Chandra](#):
> >
> > Chat channel settings to notify for everything (though I think it does not affect emails).
> 
> To clarify, this is not a channel-wide setting, but a user preference _for that channel_. But what you’re showing are the defaults, so I’d suspect that most of the 313 members have it set that way.

Thanks for the clarification. I had actually thought these were channel settings admin could change. Tbh, ‘Settings’ sounds so much like an admin control.

> [@mcwumbly](#):
>
> Are you sure they were away? If they were on the site, then the notification will not send an email.

> [@mcwumbly](#):
>
> OK, that’s pretty strong evidence that _something_ isn’t working as expected here. I would have guessed that more than 2 out of 313 people would be away. Is is possible that they were all on the site at that time?

Yes, it is safe to say the bulk of them (if not all) were away in the preceding 15 minutes (I wish we had that kind of engagement 😊 ). I picked a non-staff account that was away and checked too.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 8, 2022, 10:10pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/18 "2022-11-08T22:10:05Z")

</div>

I think I have managed to replicate this. 🙂 ✋

I couldn’t on my existing test site, but wondered if it was because I had already done/changed/tweaked something previously that may have affected it, so I spun up a new one and tried it on that.

- Created fresh site
- Enabled chat, and added `everyone` to `chat_allowed_groups` (alongside `staff`)
- Signed up and logged in three test users, auto-enrolled them in ~general channel (and made one admin). Logged them all out.
- Made a cup of tea
- As main admin, ensured they were members of the channel and pinged them with `@all`  
  
- All received notifications
- Only the admin user was sent an email about it

 ![Untitled](https://global.discourse-cdn.com/meta/original/4X/1/5/0/15003d0d1cf22dd383105f29680071145a9544c0.png)

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [November 8, 2022, 10:58pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/19 "2022-11-08T22:58:16Z")

</div>

@JammyDodger - Did you change the value of the `chat allowed groups` setting? if it’s set to only `staff`, that would explain why only the admin was emailed.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 8, 2022, 11:42pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/21 "2022-11-08T23:42:13Z")

</div>

I enabled chat, and added `everyone` at the same time. 👍 (sorry, I missed it out of the step-by-step. I’ll add it in now)

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/6/2/e621af274cf6f2ae13f0efdea6ef9f8299c39e63.png)

I think I’ve clocked it @Roman . ✋ If I add `everyone` to `chat_allowed_groups`, everyone gets to access chat and receive notifications, but doesn’t get the `@all` emails. However, if I add `trust_level_0` then the non-staff test-users get emails about the `@all` mentions.

---

<div class="post-metadata">

### Author: ![Chandra](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Chandra](https://meta.discourse.org/u/Chandra)
#### Post date: [November 9, 2022, 5:20am UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/22 "2022-11-09T05:20:17Z")

</div>

Wow, what an investigation! 👏

I checked and have staff, everyone in chat allowed groups on my site.

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [November 9, 2022, 1:38pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/23 "2022-11-09T13:38:03Z")

</div>

Thanks @JammyDodger 🎉

We need to handle the `everyone` case differently because it’s not like other groups. I have a fix ready here:

[https://github.com/discourse/discourse/pull/18955](https://github.com/discourse/discourse/pull/18955)

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [December 7, 2022, 3:52pm UTC](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556/24 "2022-12-07T15:52:29Z")

</div>

@alehandrof is reporting that some users are not getting email notifications for messages in a group chat:

> I’m trying out chat with specific people and folks are reporting that “I didn’t receive any email letting me know that someone add a comment in chat, even I have the right setting for the email notification.”

The users say they have their preferences set to the default, and were not active recently:

 ![Screenshot 2022-12-07 at 10.42.15.png](https://global.discourse-cdn.com/meta/original/4X/0/b/a/0ba5d3a07ac755ec0a0116bdfdee4a135a0d8ab3.png)

And group direct messages have their “channel” setting default to receive notifications “For all activity” so notifications should not require a @mention.

On the other hand, Alex (admin) is receiving email notifications directly.

Alex, can you confirm which version your site is currently running?

> **chat transcript**
>
> Originally sent in [chat feedback](https://meta.discourse.org/chat/c/-/129)
> 
> ![](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/48/119526_2.png)
> 
> alehandrof
> 
> I'm trying out chat with specific people and I don't quite understand how/when it notifies people by email.
> 
> The relevant setting seems to be this one:
> 
> ![Screenshot 2022-12-07 at 10.42.15.png](https://global.discourse-cdn.com/meta/original/4X/0/b/a/0ba5d3a07ac755ec0a0116bdfdee4a135a0d8ab3.png)
> 
> But folks are reporting that "I didn't receive any email letting me know that someone add a comment in chat, even I have the right setting for the email notification."
> 
> What am I missing here?
> 
> ![](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/48/103861_2.png)
> 
> mcwumbly
> 
> @alehandrof I'm guessing the missing bit is that emails are only sent to people who are @mentioned, not for all messages in channels they happen to be in
> 
> Users also have a per channel setting to opt in to get notifications for all activity. Maybe try that? I can't remember if emails are sent in that case or not.
> 
> ![](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/48/119526_2.png)
> 
> alehandrof
> 
> But surely if I'm sending a chat to a group of people (not a channel) I mean to address those specific people, no?
> 
> Also, in that group of 3, Ireceived email notifications even when I'm not being @mentioned.
> 
> Example email that apparently only I received
> 
> ![Screenshot 2022-12-07 at 14.50.05.png](https://global.discourse-cdn.com/meta/original/4X/2/5/c/25cd716972ed500a560bf566329d3d9e78a8a913.png)
> 
> Why would I receive it, but not them? (I am an admin, if that makes a difference.)
> 
> I just noticed what you said about the settings. I'll follow up with them to see what their settings are like. But if those settings are impacting this behavior, it's a bit unclear, as they only mention desktop and mobile notifications, and nothing about email.
> 
> FWIW, I did check and at least one of my colleagues has the same settings as me. So I remain stumped about how the chat handles email notifications.
> 
> ![](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/48/103861_2.png)
> 
> mcwumbly
> 
> Oh, good point. I think that should send an email notification as "For All Activity" is the default notification level for direct messages (including those with multiple people)
> 
> I'm going to turn this into a topic so we can dig in more.

[Next page](https://meta.discourse.org/t/notification-emails-not-being-sent-for-chat-as-per-user-preference/244556.md?page=2)
