Closed NicolaiSoeborg closed 1 month ago
FormatOptions.International
is more-or-less meant for this already.
I guess users of this library can also do something like:
if (mailbox.IsInternational) mail = mailbox.LocalPart + "@" + MailboxAddress.IdnMapping.Encode(mailbox.Domain)
Alternatively, you can do this instead:
var email = MailboxAddress.EncodeAddrspec (mailbox.Address);
That said, perhaps the parser shouldn't decode International Domain Names and/or perhaps a InternationalAddress
property could be added and Address
could enforce a punycode encoded address?
The only issue with that is it would break existing expectations, so perhaps a better approach would be to add LegacyAddress
or SafeAddress
or something (not sure I like either property name, but you get the idea).
Before I jump out of the starting gate, though, what scenarios do you need supported, exactly?
FormatOptions.International
is set to true
?MailboxAddress.Address
(or a replacement property) to be punycode encoded for convenience?mailbox.ToString(FormatOptions)
to output the punycode encoded address?Sounds like you want option 3, but what about the others?
Alternatively, is MailboxAddress.EncodeAddrspec (mailbox.Address)
enough now that you know about that option?
BTW, if you only ever want punycode-encoded domains, another option is to swap out the MailboxAddress.IdnMapping
implementation to one that doesn't encode/decode (or one that always converts into the encoded version).
You just need to implement the IPunycode
interface: https://mimekit.net/docs/html/T_MimeKit_Encodings_IPunycode.htm
I'm going to close this because I haven't heard any response, but if there is still interest in this we can reopen and have more discussion on how best to meet your needs.
Is your feature request related to a problem? Please describe. A lot of places requires working with punycoded mails as the IDN form is not handled correctly. But when parsing, mails are turned into IDN form, i.e.
MimeKit.MailboxAddress.Parse("X@xn--sb-lka.org").Address == "X@søb.org"
Describe the solution you'd like It would be nice with an option to keep the address in punycoded form.
Describe alternatives you've considered I guess users of this library can also do something like:
Additional context This is a suggestion for adding that. Comments are welcome!