This looks pretty slick, nice work.
There is mention of testing.. I’ve got a new discourse instance that’s up and running now, but not scheduled to be in production for a week or so. I can offer it for real-world testing (and can grant access as needed).
As for the setup of this, looking at the new variable in the mail-receiver, I wonder:
If DISCOURSE_SMTP_SHOULD_REJECT_ENDPOINT is going to be optional, should that be commented out by default?
If it should be on by default, maybe there should be just one variable to set, like
DISCOURSE_ADMIN_URL
I’m suggesting admin URL as it would have to take in to account any subfolder. Using this, the paths to /email/handle_mail and email/smtp_should_reject.json could be implied by the mail-receiver itself.