Wrong rejection email is being sent

A user just forwarded me an error message he received when he tried to reply to a PM via email. From what I can tell, the reason why his reply-email was rejected by discourse is that he used a different email address than the one he’s registered with on discourse. But the error message he received read

Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?

with the subject line:

Email issue – Posting error

Apart from this obviously being the wrong rejection message being sent, I am also confused where that message comes from in the first place. I can see the text content element topic_not_found with exactly that text, but the email template Email Reject Topic Not Found (where I’d expect this copy to be used, based on it’s name) is entirely different.

So I’m not sure what’s going on, but something is wrong.

Right but how can the software tell the difference between


mailing a topic and someone that’s expected like


Was the topic closed or deleted? Or is this specific to PM? We can’t reveal the PM…

You lost me there. I don’t know how the software does it, but I see an email templates called Email Reject User Not Found which tells the user this

Your reply was sent from an unknown email address. Try sending from another email address, or contact a staff member.

So I was assuming that it’s possible…


I can’t say. All I know at this point is that the issue exists with PMs.

Not sure what you mean by that. Do you mean the error message can’t reveal to the unknown user what PM s/he is trying to reply to? - Of course not. IMO, the expected behaviour in the specific case described would have been that the Email Reject User Not Found template is used instead of that unidentifiable template.

I can’t repro this.

  1. Sign up on try.discourse.org with a new user
  2. Turn on “email me on all messages even if I am here”
  3. Send a PM to this user
  4. Get email
  5. Copy reply-to address and paste it into a new email from a totally different email account

I get a proper email response

1 Like

The steps to reproduce are slightly different. Instead of merely copying and pasting the reply-to address into an entirely new email, you have to reply to the actual email you received so that all the headers are included. So, technically speaking you have to either set up the new user account so that it forwards emails to another account or you need to be able to switch the sender address in your email client when replying.

I was making the wrong when I assumed earlier that the message is rejected because of the wrong sender. The actual rejection email type is: email_reject_invalid_post_specified.


I was able to repro by forwarding the original mail to another account (random outlook email address I have), then replying to that mail but editing the reply email address to be the correct one – rather than the person who forwarded the email.

Net result, original email was included in the body… versus a blank email sent to the reply address.

Can you look into this @zogstrip? It does seem something in the actual forwarded email is triggering an incorrect error here, and incorrect errors are very bad…


Any news on this? I just had another confused user due to this issue…

I am also beginning to see some email rejection strangeness here…

Some user’s reply emails will get the dreaded Something has gone wrong. rejection. Thing is, other users seem to be replying to other posts perfectly fine.

And then the same user replied to some other posts and didn’t get the rejection. So, all-in-all, quite random.

Here is a recent one:

Return-Path: <fangshuixia@chenhsong.com.hk>
Received: from imss.chenhsong.com.hk ([]) by mail.chenhsong.com.hk (Netscape Messaging Server 4.15) with ESMTP id OWZ5G400.30D for <support@chenhsong.com>; Thu, 28 Sep 2017 13:19:16 +0800
Received: from imss.chenhsong.com.hk (unknown []) by IMSVA (Postfix) with ESMTP id 6F4A14C05E for <support@chenhsong.com>; Thu, 28 Sep 2017 13:31:27 +0800
Received: from z0400jt (unknown []) by imss.chenhsong.com.hk (Postfix) with SMTP id 40C324C05D for <support@chenhsong.com>; Thu, 28 Sep 2017 13:31:27 +0800
Date: Thu, 28 Sep 2017 13:31:49 +0800
From: Ricky Fang <fangshuixia@chenhsong.com.hk>
Reply-To: Ricky Fang <fangshuixia@chenhsong.com.hk>
To: Chen Hsong Technical Support Forums <support@chenhsong.com>
Message-ID: <5224D9B7BB1D42619C5C22669DA9C66C@szchit>
In-Reply-To: <topic/334/1045@support.chenhsong.com>
References: <CAGOzJbri5CsF2SHFYOCia4LtYEEwnA2qNq=3_1u5nrryE6yXuQ@mail.gmail.com>
Subject: Re: [Chen Hsong Technical Support Forums] [Support Circle
 1/Indonesia] JM328-C2-SVP/2 (SN:576716, 2015.12) -- Err 13 alarm
Mime-Version: 1.0
Content-Type: multipart/mixed;
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Mailer: Microsoft Windows Live Mail 15.4.3555.308
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3555.308
X-TM-AS-Product-Ver: IMSVA-
X-TM-AS-Result: No--31.215-5.0-31-10
X-imss-scan-details: No--31.215-5.0-31-10
X-TMASE-Result: 10--31.215200-10.000000
X-TMASE-MatchedRID: OoEa6u7Uk5/7jDJYVMdknJakKUl6DoaaYLcd4sC1A7APcq8X4eHiTKOK
X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0,39:0-0

This particular line should encode the ID of the post to reply to:

In-Reply-To: <topic/334/1045@support.chenhsong.com>

I checked and topic #334 is there, with post #1045 also being a valid post in that topic.

The user fangshuixia@chenhsong.com.hk is a valid active user.

Rejection error is: Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?

Sorry, I traced it.

Turns out that this particular user is @-mentioned in a post, and got an email, and so was compelled to reply.

But this code:


disallows the post and then sent over a very cryptic error message.

Perhaps this error message really needs to be changed to something like You don't have permission to post your reply in this topic.

EDIT: Something like this:

topic = Topic.unscoped.where(id: manager.args[:topic_id]).first

unless !topic.blank? && !topic.trashed?
  result = NewPostResult.new(:created_post, false)
  result.errors[:base] << I18n.t(:topic_not_found)
  return result

unless manager.user.guardian.can_create_post_on_topic?(topic)
  result = NewPostResult.new(:created_post, false)
  result.errors[:base] << I18n.t(:no_permission_to_post_in_topic)
  return result

Change the first condition to

unless manager.user.guardian.can_see?(topic) && !topic.trashed?

Staff obviously shouldn’t be posting on deleted topics via email, but you should be doing the full suite of permission checks.