# Getting E-Mails from inactive users

**URL:** https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961
**Category:** Support
**Created:** [2016年六月17日 16:57 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961 "2016-06-17T16:57:12Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月17日 16:57 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/1 "2016-06-17T16:57:12Z")

</div>

I’m using incoming mail support for group messaging with staged users.

This works fine if the address the message is coming from is new. However, I am [re-purposing a Discourse installation for a yearly event](https://meta.discourse.org/t/re-purposing-a-discourse-installation-for-a-yearly-event/34670), and some old users are stuck with an inactive accounts they can no longer log in to.

When such a user sends a mail to Discourse, they are rejected with `Email::Receiver::InactiveUserError`.  
What’s the best method to prevent this issue? Would replacing the mail address of the inactive accounts work?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年六月17日 18:46 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/2 "2016-06-17T18:46:42Z")

</div>

Any thoughts here @zogstrip?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月20日 15:16 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/3 "2016-06-20T15:16:25Z")

</div>

The `InactiveUserError` happens only when the user is **not** activated and **not** staged. If you want your users to be able to send emails in, you will have to either activate their account or mark them as staged.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月20日 18:56 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/4 "2016-06-20T18:56:19Z")

</div>

Can I mark existing, inactive users as staged? Would that have any side effects?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月20日 19:37 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/5 "2016-06-20T19:37:15Z")

</div>

Other than enabling them to send emails in, none 😉

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月21日 04:59 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/6 "2016-06-21T04:59:03Z")

</div>

How can I do that, then? The admin UI does not offer this option.

Will they return to normal if they ever log in?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月21日 08:21 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/7 "2016-06-21T08:21:28Z")

</div>

> [@fefrei](#):
>
> How can I do that, then?

You’ll have to use the rails console or run a SQL query.

> [@fefrei](#):
>
> Will they return to normal if they ever log in?

Yes.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月21日 09:11 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/8 "2016-06-21T09:11:33Z")

</div>

> [@zogstrip](#):
>
> Yes.

Hm, it looks like this doesn’t work.

I had a non-active, staged user (that had been disabled via the interface and staged via Rails). After the user logged in (via SSO), he had to confirm has address, became active and could log in, but is still staged:

 ![](https://global.discourse-cdn.com/meta/original/3X/1/7/171514bff4e38f14fe4b56bed7923658947ef339.png)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月21日 09:16 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/9 "2016-06-21T09:16:58Z")

</div>

Hmm, it might not unstage when using SSO. Having a look.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月21日 09:22 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/10 "2016-06-21T09:22:16Z")

</div>

Thanks a lot!

In the meantime, for anyone who wants to try the same approach, here’s what I ran on the rails console (`rails c` inside the container):

```ruby
User.where({ active: false }).update_all({ staged: true })

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月21日 09:24 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/11 "2016-06-21T09:24:51Z")

</div>

You can do _slightly_ shorter 😉

```ruby
User.where(active: false).update_all(staged: true)

```

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月21日 09:25 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/12 "2016-06-21T09:25:48Z")

</div>

I’ve given up understanding Ruby’s syntax a long time ago – even my version took many tries to be correct. Thanks for the shorter version 😉

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年六月21日 09:29 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/13 "2016-06-21T09:29:22Z")

</div>

Just pushed a fix 🚁

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

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年六月21日 09:54 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/14 "2016-06-21T09:54:24Z")

</div>

After a journey into `tests-passed` lands, I can confirm this is fixed. Thanks a lot!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年六月21日 09:55 UTC](https://meta.discourse.org/t/getting-e-mails-from-inactive-users/45961/15 "2016-06-21T09:55:53Z")

</div>


