1# Unicode support23maddy has the first-class Unicode support in all components (modules). You do4not have to take any actions to make it work with internationalized domains,5mailbox names or non-ASCII message headers.67Internally, all text fields in maddy are represented in UTF-8 and handled using8Unicode-aware operations for comparisons, case-folding and so on.910## Non-ASCII data in message headers and bodies1112maddy SMTP implementation does not care about encodings used in MIME headers or13in `Content-Type text/*` charset field.1415However, local IMAP storage implementation needs to perform certain operations16on header contents. This is mostly about SEARCH functionality. For IMAP search17to work correctly, the message body and headers should use one of the following18encodings:1920- ASCII21- UTF-822- ISO-8859-1, 2, 3, 4, 9, 10, 13, 14, 15 or 1623- Windows-1250, 1251 or 1252 (aka Code Page 1250 and so on)24- KOI8-R25- ~~HZGB2312~~, GB1803026- GBK (aka Code Page 936)27- Shift JIS (aka Code Page 932 or Windows-31J)28- Big-5 (aka Code Page 950)29- EUC-JP30- ISO-2022-JP3132_Support for HZGB2312 is currently disabled due to bugs with security33implications._3435If mailbox includes a message with any encoding not listed here, it will not36be returned in search results for any request.3738Behavior regarding handling of non-Unicode encodings is not considered stable39and may change between versions (including removal of supported encodings). If40you need your stuff to work correctly - start using UTF-8.4142## Configuration files4344maddy configuration files are assumed to be encoded in UTF-8. Use of any other45encoding will break stuff, do not do it.4647Domain names (e.g. in hostname directive or pipeline rules) can be represented48using the ACE form (aka Punycode). They will be converted to the Unicode form49internally.5051## Local credentials5253'sql' storage backend and authentication provider enforce a number of additional54constraints on used account names.5556PRECIS UsernameCaseMapped profile is enforced for local email addresses.57It limits the use of control and Bidi characters to make sure the used value58can be represented consistently in a variety of contexts. On top of that, the59address is case-folded and normalized to the NFC form for consistent internal60handling.6162PRECIS OpaqueString profile is enforced for passwords. Less strict rules are63applied here. Runs of Unicode whitespace characters are replaced with a single64ASCII space. NFC normalization is applied afterwards. If the resulting string65is empty - the password is not accepted.6667Both profiles are defined in RFC 8265, consult it for details.6869## Protocol support7071### SMTPUTF8 extension7273maddy SMTP implementation includes support for the SMTPUTF8 extension as74defined in RFC 6531.7576This means maddy can handle internationalized mailbox and domain names in MAIL77FROM, RCPT TO commands both for outbound and inbound delivery.7879maddy will not accept messages with non-ASCII envelope addresses unless80SMTPUTF8 support is requested. If a message with SMTPUTF8 flag set is forwarded81to a server without SMTPUTF8 support, delivery will fail unless it is possible82to represent envelope addresses in the ASCII form (only domains use Unicode and83they can be converted to Punycode). Contents of message body (and header) are84not considered and always accepted and sent as-is, no automatic downgrading or85reencoding is done.8687### IMAP UTF8, I18NLEVEL extensions8889Currently, maddy does not include support for UTF8 and I18NLEVEL IMAP90extensions. However, it is not a problem that can prevent it from correctly91handling UTF-8 messages (or even messages in other non-ASCII encodings92mentioned above).9394Clients that want to implement proper handling for Unicode strings may assume95maddy does not handle them properly in e.g. SEARCH commands and so such clients96may download messages and process them locally.