Body of message in /admin/email-logs/rejected is sometimes displayed as gobbledegook

AI-generated summary

A user reported that the body of rejected emails in /admin/email-logs/rejected sometimes displays as garbled text (e.g., question marks in diamonds) rather than plain text Jonathan5. The issue appears primarily in “old destination address” and “invalid post” messages Jonathan5. NateDhaliwal requested a screenshot, which Jonathan5 provided.

supermathie suggested the culprit might be Microsoft Exchange, noting that it often erroneously sends opaque references to internal data stores via SMTP. Jonathan5 confirmed the presence of Exchange headers but noted that not all Exchange emails are affected. supermathie attributed the issue to “bad software” and mentioned the need to monitor wire protocol traffic to confirm if the data is truly corrupted.

Ultimately, supermathie identified and fixed a bug in Discourse that was mangling emails saved to the database. The fix is available in pull request #37125, which should resolve the display issue once deployed.

Sometimes it displays as plain text as expected, but sometimes it displays the way characters are shown when the encoding is wrong – question marks within diamond symbols, question marks within squares, etc.

Hi there, could you send an example/screenshot of the issue? Thanks!

This sort of stuff: 6<�g8�����

It seems to show on “old destination address” and “invalid post” messages. I don’t have a lot to go on as there aren’t many to check.

Are these messages sent from Exchange?

I ask because I’m familiar with this problem and 100% of the time I’ve seen it, Exchange was the sender and the culprit.

My guess is that it’s erroneously sending out an opaque reference to an internal data store via SMTP. In the cases where it’s been solved, the sender did something to fix it.

Yes there are Exchange headers. I wonder what’s up.

Though not all Exchange emails appear like this. There are some “Bad destination address” rejected emails that appear as ordinary plain text.

:person_shrugging: bad software sending out bad emails

Indeed, not all Exchange emails are bad :laughing:

Should anyone come across this topic and actually administer such a bad server, I still want to monitor the wire protocol traffic to determine if it really is 100% bad data or of something else is going on.

(for weird problems like this, I never 100% trust everything until I see it with my own eyes)

I have identified and fixed a bug in Discourse that mangled emails saved to the database:

https://github.com/discourse/discourse/pull/37125

Once this fix is pulled in, it should be fine.