Send rejection email for unrecognised errors

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:

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.


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

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:


Well yes that is what I meant when I wrote

1 Like

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



Unrecognized error type (RuntimeError: ) when processing incoming email

  /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 I’ll PM you the full logs, with the raw email.

Precisely, and why I put this in #feature rather than #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.


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

1 Like

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

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:

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

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


Sure, PR welcome to handle this case!




@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}.


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.