jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.82k stars 371 forks source link

Email sender comes up as blank #416

Closed FSGRSolutions closed 6 years ago

FSGRSolutions commented 6 years ago

Hi Jeffrey, again, thank you for your great work. I'm running into an issue with some messages where I cannot get the email sender. I use the following code:

For Each mailbox As MailboxAddress In message.From.Mailboxes email.From = email.From & IIf(mailbox.Address <> "", mailbox.Address, mailbox.Name) & ";" Next

When I look into the POP3 log for the message, I see:

S: From: =?utf-8?Q?Telenor_Elektronikus_Sz=C3=A1mla?=
S:  <Telenor Elektronikus Sz#mla <eszamla@telenor.hu>
S: Subject: =?utf-8?Q?Elektronikus_sz=C3=A1mla_=C3=A9rtes=C3=ADt=C5=91__=28B?=
S:  =?utf-8?Q?izalmas=29?=

Subject is parsed and is populated properly.

Also, at the beginning of the message, I see: S: Return-Path: eszamla@telenor.hu

Let me know if there's any way to expose the return path.

jstedfast commented 6 years ago

The problem is the '<' character at "<Telenor" - that is invalid syntax.

If you try using InternetAddressList.Parse() on the string value of the From header you'll get an exception that tells you the problem.

I recommend submitting a bug report to the makers of the sending software.

FSGRSolutions commented 6 years ago

Thank you for your prompt response; any way to expose the return-path? would this be recommended?

jstedfast commented 6 years ago

You could look at message.Headers["Return-Path"] (case of the header name is not important), but it's not something that is necessarily guaranteed to exist or be relevant.

Doesn't hurt to try, though, I suppose. You could also check the Reply-To address if that exists.