-
-
Notifications
You must be signed in to change notification settings - Fork 867
Unable to create MailboxAddress for empty email address #775
Copy link
Copy link
Closed
Labels
questionA question about how to do somethingA question about how to do something
Description
Describe the bug
We are using MailKit/MimeKit to relay emails.
However it does not handle sending emails to from "<>", for more info about empty email addresses see here, So when you try to send an email from an empty address it throws a MimeKit.ParseException exception.
To Reproduce
Below is my code where the first line throws a MimeKit.ParseException
var from = new MailboxAddress("<>"); // throws MimeKit.ParseException
await client.SendAsync(email.Message, from, to);Same code but using MailboxAddress.Parse
var from = MailboxAddress.Parse("<>"); // throws MimeKit.ParseException
await client.SendAsync(email.Message, from, to);Exception:
MimeKit.ParseException
HResult=0x80131537
Message=Invalid local-part at offset 0
Source=MimeKit
StackTrace:
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 Test.Program.<Main>d__0.MoveNext() in D:\other code\C#\Test\Test\Program.cs:line 39
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Test.Program.<Main>(String[] args)
Expected behavior
I can use mailKit to send emails from an empty address
Desktop (please complete the following information):
- OS: Windows 10, 64 bit. As well as tested on AWS ECS (Amazon Linux i think)
- Mailkit version 2.0.7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionA question about how to do somethingA question about how to do something