Wrong rejection email is being sent


(Christoph) #1

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.


(Jeff Atwood) #2

Right but how can the software tell the difference between

rando@example.com

mailing a topic and someone that’s expected like

myname@example.com

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


(Christoph) #3

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…

No.

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.


(Jeff Atwood) #4

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


(Christoph) #5

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.


(Jeff Atwood) #6

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…


(Christoph) #7

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


(Stephen Chung) #9

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 ([192.2.2.230]) 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 [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F4A14C05E for <support@chenhsong.com>; Thu, 28 Sep 2017 13:31:27 +0800
Received: from z0400jt (unknown [128.0.10.86]) 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>
 <topic/334/1045@support.chenhsong.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;
 boundary="----=_NextPart_000_041A_01D3385E.231DE780"
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-GCONF: 00
X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.1.0.1062-23356.005
X-TM-AS-Result: No--31.215-5.0-31-10
X-imss-scan-details: No--31.215-5.0-31-10
X-TMASE-Version: IMSVA-9.1.0.1631-8.1.1062-23356.005
X-TMASE-Result: 10--31.215200-10.000000
X-TMASE-MatchedRID: OoEa6u7Uk5/7jDJYVMdknJakKUl6DoaaYLcd4sC1A7APcq8X4eHiTKOK
 AoYvxV6O4kHyKE737jMyAVtuM0WmdYv73wEu0Nx7mGSSol4Uei2D5J8KjbO0a10cUmVUESQrMOI
 th1ZIjBYdI+1cmjljCwMWCgdCzp+apvwZ9GmdwDM2vbWaKPnQ26fnINz0/CVcCX0hYHHH6QGeVl
 Vk+nA5BuKx1hBR/cO5R3/YVKCZ7n8FJG8ZmXyKdRmyTBaqiJvcqGUoeeE5ZPaGWF76zpjEcauXB
 HcJydGNNKO9ekWIDjZZJq170V074IgQP9GwUC5rkos2tunL8DQ2XU7aYfNqGcpVP1437pHlUrOb
 qwVsq78v1OGI1GjxcUSlex5NhCLDSJA7ysb1rf7tPu7zIBu6oxi9RS/27dWNARJizF67UaO+OfV
 0nydAKc+P7RYqeBFfCtEHdpp2wcCUO0lP0LYg0tWFxOQKreJyGYMdbM0Om1jgn8HV6/VM7aiWTo
 gCqGa87uXsxANhR1N/Xgn9EbUCW7qQyAveNtg6rLALtod6A6Z40NDah2ISIV4EgAZ9NfNJR5VDm
 9eOTwz60JsXSYUR0YcWjt28Nz4wjc2CQSoA3RGdsptW1GypMJp5yGjWmTixSqYvgEkoBesjkA2G
 uUdtYbSjPyL4ViYMp/nT+xnI1R3vVbHa5Rs8t73hJuaRJWl0rNP+37owa0+iQ0y1c+y1kzQhcXt
 hdn8LZyQ4z3sAkNFhaj10i6TXQPVFR4sC8dPyHAwy0XhreD2dymcYsJ8TpQpACfGtoeF/MsWUPB
 Bu17YyQF5x4l70KIRrPRzYTqwugxsfzkNRlfIooR44AkZiYtTU5/udFkX1K6aE9YGkEBheu6llO
 oM7BmhVFfiT3ALa24sRer/5DwdVLFiG1CgpCl+uXana0UOPMu/igXq0Eg6DMm/a8UnLTqdaXcOf
 AuNLh787jR0t3M6wFMlIPaIBbQ==
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?


(Stephen Chung) #10

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
end

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
end

(Kane York) #11

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.