<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1822615684631785&amp;ev=PageView&amp;noscript=1"/>

Upgrading MimeKit broke our email address parser

This article is intended for software developers or those interested in the code behind GMass.

GMass is written mostly in C# and JavaScript, and the C# backend makes heavy use of a popular email parsing component called MimeKit. In face, MimeKit, has become so popular that Microsoft is now recommending that developers use it as the standard instead of Microsoft’s own SmtpClient library.

Over the weekend, we updated some of the software components that GMass is built on in preparation for a big feature launch, and in doing so, we updated MimeKit from version 1.12 to the latest release 1.18. That upgrade unfortunately broke some of our email address validation code, and many users saw a “token offset” error as a result.

Here’s what happened. Previously, in version 1.12, the following scenarios would pass without throwing an exception:

MimeKit Sample 1
MimeKit Code Sample: These scenarios pass, and no exception is thrown.

After updating to version 1.18, the top two of the three scenarios do throw an exception:

MimeKit Sample 2
MimeKit Code Sample: After updating to version 1.18, these throw a parsing exception.

The impact on GMass is such that if you’re connecting to a Google Sheets spreadsheet, and your column containing email addresses has a bad data value that is an invalid email address, such as “[email protected];[email protected]”, whereas before our code would handle this appropriately and eventually filter the bad entry out, now all of a sudden, our code was throwing an exception.

Making matters more complex was that the MimeKit TryParse didn’t always catch a string that could not be converted into a MimeKit.MailboxAddress object. For example:

MimeKit Sample 3
MimeKit Code Sample: TryParse returns true, but the string still can’t be converted to a MailboxAddress object.

In the above samples, TryParse returns false for “[email protected];[email protected]” but returns true for “test<[email protected]>”. It returns true for the latter because it assumes that the part outside the angle brackets is the Name, and so Name=test and [email protected]. Our code though attempts to create a MailboxAddress object from the whole string, and in this case, the parse into Name and Address doesn’t happen, as the constructor assumes that the entire string represents just the Address portion of the object.

We did check the Release Notes for MimeKit before deploying the update, but there was nothing indicating the change in email parsing rules. Still however, we are eternally grateful to Jeffrey Stedfast for building and maintaining the MimeKit library for the .NET framework. Without it, my job as a software developer parsing and assembling email messages would be far more difficult.

 

See why GMass has 300k+ users and 7,500+ 5-star reviews


Email marketing. Cold email. Mail merge. Avoid the spam folder. Easy to learn and use. All inside Gmail.


TRY GMASS FOR FREE

Download Chrome extension - 30 second install!
No credit card required
Love what you're reading? Get the latest email strategy and tips & stay in touch.
   


1 Comment

Leave a Reply

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

Transform your Gmail account into an email marketing powerhouse

GMass is easy to learn and easy to use — but brings unbelievable email power into Gmail

Try GMass for free Then check out the quickstart guide to send your first mail merge email in minutes!

GMass

Share This