# Send rejection email for unrecognised errors

**URL:** https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556
**Category:** Feature
**Created:** [6월 15, 2017, 2:33오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556 "2017-06-15T14:33:19Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [6월 15, 2017, 2:33오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/1 "2017-06-15T14:33:19Z")

</div>

Yesterday we had an email to Discourse which errored out while processing with:

`Unrecognized error type (RuntimeError: ) when processing incoming email`

We only found out about this because the user looked on the site for their reply, couldn’t find it, and alerted me. While it did appear in the logs, I don’t check them particularly regularly.

The simplest ‘solution’ to this I see is sending a rejection message to users if there’s been any error during processing, telling them to try again or alert an admin.

Looking at the source, it seems like not sending a message when there’s an unrecognised error is intentional:

> <https://github.com/discourse/discourse/blob/main/lib/email/processor.rb#L36-L88>

While I understand not giving specific information about the error isn’t really possible, Discourse should at least let the user know their email hasn’t been posted so they don’t naively assume it has.

---

<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: [6월 16, 2017, 2:42오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/2 "2017-06-16T02:42:56Z")

</div>

What was the actual error? Can you share the error info? @zogstrip any thoughts on this, should we do a better error here?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [6월 16, 2017, 3:05오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/3 "2017-06-16T03:05:39Z")

</div>

I think the problem being raised isn’t so much the specific error, so much as who is notified when random unexpected errors occur. Only admins, if they look in the logs, get to see that the delivery has failed; senders just get radio silence:

> [@LeoMcA](#):
>
> Discourse should at least let the user know their email hasn’t been posted so they don’t naively assume it has.

---

<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: [6월 16, 2017, 8:32오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/4 "2017-06-16T08:32:19Z")

</div>

Well yes that is what I meant when I wrote

> [@codinghorror](#):
>
> should we do a better error here?

---

<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: [6월 16, 2017, 10:52오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/5 "2017-06-16T10:52:51Z")

</div>

Would love to get the email that’s triggering that error as this is the first time I’m seeing it.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [6월 16, 2017, 2:03오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/6 "2017-06-16T14:03:40Z")

</div>

> [@codinghorror](#):
>
> What was the actual error? Can you share the error info?

Sure:

```
Unrecognized error type (RuntimeError: ) when processing incoming email

Backtrace:
  /var/www/discourse/lib/discourse.rb:26:in `execute_command'
  /var/www/discourse/lib/upload_creator.rb:137:in `convert_to_jpeg!'
  /var/www/discourse/lib/upload_creator.rb:42:in `block in create_for'
  /var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
  /var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
  /var/www/discourse/lib/upload_creator.rb:34:in `create_for'
  /var/www/discourse/lib/email/receiver.rb:580:in `block in create_post_with_attachments'
  /var/www/discourse/lib/email/receiver.rb:573:in `each'
  /var/www/discourse/lib/email/receiver.rb:573:in `create_post_with_attachments'
  /var/www/discourse/lib/email/receiver.rb:551:in `create_reply'
  /var/www/discourse/lib/email/receiver.rb:101:in `process_internal'
  /var/www/discourse/lib/email/receiver.rb:50:in `block in process!'
  /var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
  /var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
  /var/www/discourse/lib/email/receiver.rb:45:in `process!'
  /var/www/discourse/lib/email/processor.rb:17:in `process!'
  /var/www/discourse/lib/email/processor.rb:11:in `process!'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:25:in `process_popmail'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:43:in `block (2 levels) in poll_pop3'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:689:in `block in delete_all'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:688:in `each'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:688:in `delete_all'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:42:in `block in poll_pop3'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:532:in `start'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:41:in `poll_pop3'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:16:in `execute'
  /var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

```

It’s a weird one, and I tried to reproduce it with the same image, but couldn’t. When the user resent the email it worked fine.

> [@zogstrip](#):
>
> Would love to get the email that’s triggering that error as this is the first time I’m seeing it.

@zogstrip I’ll PM you the full logs, with the raw email.

> [@mpalmer](#):
>
> I think the problem being raised isn’t so much the specific error, so much as who is notified when random unexpected errors occur.

Precisely, and why I put this in #Contribute > Feature rather than #Contribute > Bug.

_As an email-only user, I want Discourse to alert me whenever my email doesn’t result in a post on Discourse, so that I know that my colleagues aren’t just ignoring me._

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [7월 19, 2017, 9:30오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/7 "2017-07-19T21:30:33Z")

</div>

Has there been any progress here? I’m willing to submit a PR implementing this if need be.

---

<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: [7월 20, 2017, 2:07오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/8 "2017-07-20T14:07:12Z")

</div>

@LeoMcA did this error happen recently? Because I can not reproduce it ☹

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [7월 20, 2017, 3:55오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/9 "2017-07-20T15:55:36Z")

</div>

It hasn’t, but we want to ensure it doesn’t happen again.

And to be clear “it” isn’t this specific error, but the problem where an email-in will error out while processing and the user has no idea it hasn’t been posted:

> [@LeoMcA](#):
>
> As an email-only user, I want Discourse to alert me whenever my email doesn’t result in a post on Discourse, so that I know that my colleagues aren’t just ignoring me.

It’s possibly easiest if I explain myself through code. Something like this is the feature I want to add:

[https://github.com/LeoMcA/discourse/commit/8a77db9225a75083f6b253d3d885b262b0a96f6f](https://github.com/LeoMcA/discourse/commit/8a77db9225a75083f6b253d3d885b262b0a96f6f)

(To be clear, this doesn’t actually implement the feature - templates, test and such still need to be written, and I’m not even sure if it’s the best way of approaching it - but hopefully it serves as a demonstration.)

---

<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: [7월 21, 2017, 10:28오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/10 "2017-07-21T10:28:36Z")

</div>

Sure, PR welcome to handle this case!

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [7월 21, 2017, 5:29오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/11 "2017-07-21T17:29:16Z")

</div>

🎉

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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [7월 21, 2017, 6:18오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/12 "2017-07-21T18:18:36Z")

</div>

@LeoMcA what do you think about adding the `contact email` site setting on the message?

So it will be:

> We’re sorry, but your email message to %{destination} (titled %{former\_title}) didn’t work.  
> There was an unrecognized error while processing your email and it wasn’t posted. You should try again, or contact a staff member at %{contact\_mail}.

---

<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: [7월 21, 2017, 11:12오후 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/13 "2017-07-21T23:12:20Z")

</div>

A very good idea indeed, but don’t use the contact email, send them to the `/about` page which can be hard-coded. The contact info is all there.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [7월 25, 2017, 10:27오전 UTC](https://meta.discourse.org/t/send-rejection-email-for-unrecognised-errors/64556/14 "2017-07-25T10:27:49Z")

</div>

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