Search code examples
asp.net-coreemail-clientmimekit

MimeKit.ParseException: Unexpected token at offset 18


I have SPA application and asp.net core 3.1 web api and MimeKit for email service.

When user register the server sends confirmation email and everything is okay. But on 1 phone device the server throws exception when the email contains underscore.

The problematic email is "[email protected]" and the error that server throws is:

MimeKit.ParseException: Unexpected token at offset 18
   at MimeKit.MailboxAddress.set_Address(String value)
   at MimeKit.MailboxAddress..ctor(Encoding encoding, String name, String address)
   at MimeKit.MailboxAddress..ctor(String address)

The weird part is that I connected the phone browser to my pc via chrome dev tools for remote debugging and when I did via pc browser emulator its working.

Note that:

  • the email is 18 chars longs so it basically fails on the and

  • The email is sent with https post in body and it is logged properly on the server

  • Email that contains dot(".") is working


Solution

  • I upgraded MimeKit from 2.6 to 3.2 and its working properly now.