Discourse is sending emails even though emailing is disabled

AI-generated summary

Users reported that Discourse continued sending emails despite having email settings configured to disable them (e.g., set to ‘non-staff’ or ‘yes’). mathias.kallberg first raised the issue after an update to 2.2.2, noting that even changing the setting didn’t stop emails. pfaffman speculated about a backed-up Sidekiq queue, but joebuhlig confirmed the bug on a beta site, where 1,000 users received unintended emails. pfaffman pointed to potential logic flaws in the code handling disable_emails settings, especially around legacy true/false vs. yes/no values. david acknowledged the bug, attributing it to a December code change, and reverted the commit while opening a PR to improve the email disable logic. The fix was later merged in a9d5ffbe, credited to david by tgxworld. This was a critical bug affecting email privacy and control, now resolved.

Hi!

Since we updated to 2.2.2 (i think it was) on the first of march Discourse began sending out emails even though we have emailing disabled.

Actually we had it set to “non-staff”, but even setting it to “yes” doesn’t help.

Any ideas why this is happening? :slight_smile:

2 Likes

Is your sidekiq queue backed up and sending stuff that was queued before you disabled mail?

I’ll confirm this one. I just had a beta site send emails to the entire user base even though the setting is at non-staff. Emails went out to 1,000 people who shouldn’t know the site exists yet.

Edit: Following up here. I decided to break the email configuration on this beta site to get emails to stop. I could trigger emails to non-staff users pretty easy with mentions and such even though the disable emails setting was at non-staff.

2 Likes

I don’t pretend to understand how things work at this level (maybe there are tests elsewhere that I don’t know about), but I don’t see how this code would skip sending if disable_emails was staff_only. Also, if I remember correctly, the old value used to be true/false, so it looks like if it had been set to true it would fail matching the yes in the test below (or maybe that would have been fixed in a migration somehow or Rails magically thinks that true and yes are the same?).

3 Likes

Thanks for the report. I think this is an unintended side effect of a change in December. I’ll get it fixed now.

8 Likes

I have reverted that commit, and opened a PR to make some further improvements to the “disable email” logic:

https://github.com/discourse/discourse/pull/7238

7 Likes

Thank you to @david for fixing this in

https://github.com/discourse/discourse/commit/a9d5ffbe3d9b40db92a745dd588f2eaedc849c5f

7 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.