MimeKit.ParseException: Invalid local-part at offset 0 on Gmail Imap

See original GitHub issue

This just started getting an exception being thrown from inside of Imap.ImapFolder.Fetch() with my gmail account. See below.

I understand that local-part refers to the part to the left of the @ in the email address. With the Imap diagnostic turned on, i found a French language messages a few messages before the location with the stack trace. It that has this in the local-part:

From: =?UTF-8?Q?Lib=C3=A9ration?= <newsletter@liberation.cccampaigns.net>

The gmail “show original” shows it as

From: "Libération" <newsletter@liberation.cccampaigns.net>

Disclaimer: I’m guessing that this is the messages that’s causing the crash. I cant be sure since the parse and download streams appear to be on different threads.

This is the full stack trace:

MimeKit.ParseException: Invalid local-part at offset 0
   at MimeKit.InternetAddress.TryParseLocalPart(Byte[] text, Int32& index, Int32 endIndex, Boolean throwOnError, String& localpart)
   at MimeKit.InternetAddress.TryParseAddrspec(Byte[] text, Int32& index, Int32 endIndex, Byte[] sentinels, Boolean throwOnError, String& addrspec, Int32& at)
   at MimeKit.MailboxAddress.set_Address(String value)
   at MimeKit.MailboxAddress..ctor(Encoding encoding, String name, String address)
   at MailKit.Net.Imap.ImapUtils.EnvelopeAddress.ToMailboxAddress()
   at MailKit.Net.Imap.ImapUtils.ParseEnvelopeAddressList(InternetAddressList list, ImapEngine engine, String format, CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapUtils.ParseEnvelope(ImapEngine engine, CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapFolder.FetchSummaryItems(ImapEngine engine, ImapCommand ic, Int32 index)
   at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponse(CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapCommand.Step()
   at MailKit.Net.Imap.ImapEngine.Iterate()
   at MailKit.Net.Imap.ImapEngine.Wait(ImapCommand ic)
   at MailKit.Net.Imap.ImapFolder.Fetch(IList`1 uids, MessageSummaryItems items, HashSet`1 fields, CancellationToken cancellationToken)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
jstedfastcommented, May 10, 2017

The MailboxAddress .ctor is not meant to parse anything. Use MailboxAddress.Parse() instead.

1reaction
ooplescommented, Jun 26, 2021

I’m stripping whitespace before I create the mailbox address but I inserted some code to show me what it’s failing at so we will see what happens

On Fri, Jun 25, 2021, 11:04 PM Jeffrey Stedfast @.***> wrote:

Something isn’t valid about them… do they have extra whitespace?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jstedfast/MailKit/issues/494#issuecomment-868935606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXO4ZL3EHT3Y3OWPKUEIFDTUU7VJANCNFSM4DIEIUTQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid local-part at offset 0 from a Workflow Email Send step.
This error message occurs when an invalid email address has been provided. Please review the email addresses that were provided to the Email...
Read more >
Cannot sent mail in Mimekit
I think you just have your MailboxAddress ctor arguments in wrong order.
Read more >
Error Save Email Message + Invalid local-part at offset 0 ...
The address string that you pass to should be in its canonical form. For example, a leading space would be an invalid format...
Read more >
Upgrading MimeKit broke our email address parser
That upgrade unfortunately broke some of our email address validation code, and many users saw a “token offset” error as a result. Here's...
Read more >
Cant send verify mail - Password Manager
I've tried all possible settings in global.override.env, even the Gmail ... ParseException: Invalid addr-spec token at offset 0 at MimeKit.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found