SmtpUtf8AddressValidationOptions Enumeration

Options for SMTPUTF8 address validation.

Definition

Namespace: MimeKit.Utils
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
[FlagsAttribute]
public enum SmtpUtf8AddressValidationOptions

Remarks

Options that change the behavior of the SmtpUtf8AddressValidator.

Members

None 0 Validate the address exactly as written. A domain label that is an A-label (i.e. begins with xn--) is rejected with ALabel.
DecodeIdn 1

Decode each A-label in the domain into its Unicode form (U-label) before validating the address.

The decoded domain is subject to all of the code point, contextual and script rules, which makes this option useful for checking whether an address that will be displayed to a user (in its decoded form) might be an attempt to spoof another address.

A-labels are decoded using MimeKit's own implementation of the Punycode algorithm described in rfc3492 rather than IdnMapping, so the results are the same on every platform and target framework. A domain label is rejected with ALabel if it is longer than 63 characters, is not valid Punycode, is not in canonical form (i.e. re-encoding the decoded label does not reproduce the original A-label), decodes to a surrogate or to only ASCII characters, or decodes to a U-label that begins or ends with a hyphen or that has hyphens in both the third and fourth positions. Any other problem with the decoded U-label is reported in the same way as it would be for a U-label that was not encoded (e.g. xn--a decodes to U+0080, which is reported as DisallowedCodePoint).

Atoms in the local-part that begin with xn-- are not IDN-encoded and are still rejected with ALabel.

AsciiIsLatin 2

Treat ASCII letters as belonging to the Latin script when checking whether an address mixes scripts.

The rules defined by draft-ietf-mailmaint-smtputf8-syntax disregard ASCII when counting scripts, which means that an address such as paypal@рaypal.com (where the first letter of the domain is U+0440 CYRILLIC SMALL LETTER ER) is considered valid. When this option is set, such an address is rejected with MixedScripts.

When this option is set, ASCII letters are counted separately for the local-part and for each label of the domain, so addresses such as иван@example.com and user@пример.com are still valid. The non-ASCII characters of the address must still all belong to a single script, so this option never accepts an address that would otherwise be rejected. However, this option rejects labels that legitimately mix ASCII letters with a non-Latin script, such as info@москва-shop.ru.

EnforceLengthLimits 4

Enforce the length limits defined in rfc5321 as extended by rfc6531.

  • The local-part must not exceed 64 octets when encoded in UTF-8 (LocalPartTooLong).
  • Each label of the domain must not exceed 63 octets when encoded as an A-label (LabelTooLong).
  • The domain must not exceed 253 octets when each of its labels is encoded as an A-label (DomainTooLong).
  • The address must not exceed 254 octets when encoded in UTF-8, which is the 256-octet limit on a reverse-path or forward-path minus the angle brackets (AddressTooLong).

The label and domain limits do not apply to address literals.

See Also