Email issue -- Unknown To: Address - Private Message

Hey All,

I am seeing a really odd issue, our community manager is getting this email:

Adore Beauty Community via amazonses.com
9:13 AM (4 hours ago)

to me
We’re sorry, but your email message to [“****** REMOVED *****”] (titled Re: Asap super b complex serum) didn’t work.

None of the destination email addresses are recognized. Please make sure that you are sending to the correct email address provided by staff.

When we try to contact a user by email im told, I believe this is from the community manager contacting via a PM in the start.

We have reply by email setup and its working:

For threads however, im struggling with this private email - is there something I need to prd / find out to debug this?

Amazon SES rewrites the “Message-IDs” of emails sent through it. This breaks one of Discourse’s security features related to incoming email.

To make it work, you can disable the “find related post with key” site setting, but be aware that it does open up the potential for users to be impersonated by email.

3 Likes

Hey @david

Thanks for this - I will set it and lets see how we go.

1 Like

I wonder if we could improve the error message a bit to better indicate the need for the Message-ID to be intact?

I think it might actually be possible to actually fix the SES problem.

SES rewrites the message IDs, which is annoying, but it gives the client the new message id in the SMTP transaction. So if we can get hold of that at the point of sending the email then swapping some stuff around here might solve the problem:

https://github.com/discourse/discourse/blob/5012d46cbd3bcf79b7351f7d2d41003496a796c5/lib/email/sender.rb#L181-L187

A slightly crude experiment I did was to set return_response: true in the Rails SMTP settings, then adjust the code above to

      begin
        val = @message.deliver_now!
        Rails.logger.error("SMTP says #{val.message}")
      rescue *SMTP_CLIENT_ERRORS => e
        return skip(e.message)
      end

And then in my logs I get

SMTP says 250 Ok 0102015e11ccfcb7-23e96y80-9c33-4cfd-baba-1555c5a26f38-000000

which is the actual message ID that SES is using.

Needs more investigation - who knows what else I’ve broken by changing those things :laughing: - but it’s an idea.

1 Like

I think improving the error message is a lot easier.

3 Likes

That is most definitely true :wink:

1 Like

OK I just changed it to

None of the destination email addresses are recognized, or the Message-ID header in the email has been modified. Please make sure that you are sending to the correct email address provided by staff.

1 Like