Just squashed a rare bug involving garbled characters in Gmail email marketing campaigns

Over the last month, a small number of users have reported garbled characters appearing in their Gmail mail merge campaigns with GMass. In most cases they reported characters like “” appearing randomly throughout the text of the email that is sent after clicking the GMass button. The issue tended to surface in emails containing non-English characters.

[Example of an email with garbled characters]

I’ve been wanting to get to the bottom of the issue for a while, but I couldn’t because I couldn’t actually reproduce the issue myself…until tonight.

Earlier today, I conducted a screen share session with a user that had experienced the bug and she was able to walk me through the steps to reproduce the bug. After capturing some data, and spending all evening investigating, I finally figured out the cause and solved the problem.

The problem only surfaced if the To field of a Gmail Draft contained an email address that contained a foreign character. The mere presence of a foreign character in a single email address would cause all individual emails sent to all recipients of the campaign to receive a message with garbled characters. Even if a test message was sent to just one test address containing non-foreign characters using the “Send Test Email” feature, that test would also contain garbled characters, because the To field contained an address with foreign characters when the “Send Test Email” button was clicked.

[Example of an email with an address in the To field containing an illegal foreign character]



For the technical types, the issue was related to the way Gmail encodes email messages in certain situations. While the standard encoding for both the HTML and Plain Text MIME parts of a Gmail Draft are encoded as quoted-printable, if an email address in the To field contains a foreign character, then the encoding of both MIME parts becomes “8bit” instead of “quoted-printable”.

[The encoding changes to 8bit, and previously Chinese characters would be garbled]

[Now Chinese characters are handled properly in the 8bit format]


This single anomaly threw off the GMass code that disassembles a message to add open and click tracking and then reassembles it for sending. The reassemby wasn’t able to output all characters in the necessary “8bit” encoding format. 

The fix was to modify how the final message is outputted so that “8bit” encoding is handled properly. This required writing to a memory stream instead of a string. I’m happy to share more details with any interested parties — just get in touch.

Leave a Reply

Your email address will not be published. Required fields are marked *