In a support thread titled ‘Email issue – Unknown To: Address - Private Message,’ Gareth_Williams reports that their community manager receives bounce-back emails when sending private messages via email, due to unrecognized recipient addresses. The issue stems from Amazon SES rewriting the ‘Message-ID’ header, which breaks Discourse’s email security feature that matches replies to original posts. david suggests disabling the ‘find related post with key’ setting as a workaround, though it introduces impersonation risk. He later proposes a potential fix by capturing SES’s new Message-ID during SMTP delivery and updating Discourse’s email sender logic here, though it requires further testing. codinghorror suggests improving the error message to clarify the Message-ID issue, which david agrees is easier. The error message was updated to include: ‘or the Message-ID header in the email has been modified.’ Gareth_Williams plans to test the workaround. The thread highlights a technical conflict between SES and Discourse’s email threading system, with both short-term and long-term solutions under consideration.
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.
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:
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 - but it’s an idea.
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.