jstedfast / MailKit

A cross-platform .NET library for IMAP, POP3, and SMTP.
http://www.mimekit.net
MIT License
6.19k stars 821 forks source link

How to create MailboxAddress instance with punycode in domain part ? #1780

Closed aldayneko closed 2 months ago

aldayneko commented 2 months ago

Hello, I have an issue when my smtp server rejects sending emails when from field contains idn address, but works fine in case of punycode value But I can't create MimeMessage where MailboxAddress contains punycode, because it always converts punycode into idn I probably might implement my custom IPunycode which doesn't do any conversion and assign IdnMapping with it, but it can be bad idea since it's static and will be applied everywhere Is there any workaround here ?

jstedfast commented 2 months ago

MailKit will use the UTF-8 version of the mailbox address when the SMTP server supports the SMTPUTF8 extension.

When it doesn't, it will use the IDN-encoded version of the mailbox address.

You can disable SMTP extensions by doing this:

client.Capabilities &= ~SmtpCapabilities.UTF8;
aldayneko commented 2 months ago

Thanks but I got it to work just creating custom IPunycode implementation which simply doesn't do any conversion and it solved my problem