# Discourse 在已禁用邮件功能的情况下仍在发送邮件

**URL:** https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231
**Category:** Bug
**Created:** [2019 年3 月 21 日 08:58 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231 "2019-03-21T08:58:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### 作者： ![mathias.kallberg](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@mathias.kallberg](https://meta.discourse.org/u/mathias.kallberg)
#### 发布日期： [2019 年3 月 21 日 08:58 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/1 "2019-03-21T08:58:36Z")

</div>

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? 🙂

---

<div class="post-metadata">

### 作者： ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### 发布日期： [2019 年3 月 21 日 10:06 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/2 "2019-03-21T10:06:28Z")

</div>

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

---

<div class="post-metadata">

### 作者： ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### 发布日期： [2019 年3 月 21 日 18:18 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/3 "2019-03-21T18:18:57Z")

</div>

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`.

---

<div class="post-metadata">

### 作者： ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### 发布日期： [2019 年3 月 21 日 20:29 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/4 "2019-03-21T20:29:24Z")

</div>

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?).

> <https://github.com/discourse/discourse/blob/main/lib/email/sender.rb#L24-L30>

---

<div class="post-metadata">

### 作者： ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### 发布日期： [2019 年3 月 21 日 20:41 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/5 "2019-03-21T20:41:13Z")

</div>

Thanks for the report. I think this is an unintended side effect of [a change](https://github.com/discourse/discourse/commit/c279792130e24dffbbdee8d6cbb0bad46cc13b72) in December. I’ll get it fixed now.

---

<div class="post-metadata">

### 作者： ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### 发布日期： [2019 年3 月 21 日 21:59 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/7 "2019-03-21T21:59:14Z")

</div>

I have [reverted that commit](https://github.com/discourse/discourse/commit/3f9e7eb3267655323a8c50e4059388be0a9d71e6), and opened a PR to make some further improvements to the “disable email” logic:

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

---

<div class="post-metadata">

### 作者： ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### 发布日期： [2019 年3 月 22 日 09:30 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/11 "2019-03-22T09:30:48Z")

</div>

Thank you to @david for fixing this in

[https://github.com/discourse/discourse/commit/a9d5ffbe3d9b40db92a745dd588f2eaedc849c5f](https://github.com/discourse/discourse/commit/a9d5ffbe3d9b40db92a745dd588f2eaedc849c5f)

---

<div class="post-metadata">

### 作者： ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### 发布日期： [2019 年3 月 25 日 10:00 UTC](https://meta.discourse.org/t/discourse-is-sending-emails-even-though-emailing-is-disabled/112231/12 "2019-03-25T10:00:09Z")

</div>

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