SmtpAddressValidationOptions Enumeration

Options for SMTP address validation.

Definition

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

Remarks

Options that change the behavior of the SmtpAddressValidator.

Members

None 0 Validate the address according to the Mailbox syntax defined in rfc5321 without enforcing any length limits.
AllowIso2022JpLocalPart 1

Allow a quoted local-part to contain Japanese text encoded using the ISO-2022-JP character encoding defined in rfc1468, such as "\u001B$BF|K\\8l\u001B(B"@example.jp.

Some legacy Japanese mail clients produce such addresses even though they are not valid according to any standard since the escape sequences used by ISO-2022-JP begin with the ESC (U+001B) control character, which is not permitted in an address.

When this option is set, a quoted local-part may switch to JIS X 0201-Roman (ESC ( J) or JIS X 0208 (ESC $ @ or ESC $ B) and back to ASCII (ESC ( B). The local-part must end in ASCII, each JIS X 0208 character must consist of two bytes in the range 0x21-0x7E, and any " or \ byte must be escaped using a quoted-pair, just as it would be anywhere else in a quoted local-part. Any other use of the ESC character or a malformed escape sequence is rejected with Syntax.

Only the syntax of the escape sequences is checked; the JIS X 0208 characters are not decoded, so a byte pair that does not correspond to an assigned character is not detected.

ISO-2022-JP text is not permitted in an unquoted local-part since the ESC ( B escape sequence that must end the text contains a (, which would begin a comment.

Since MailboxAddress does not permit control characters within a quoted local-part, such addresses can only be validated using the String overloads of SmtpAddressValidator.

EnforceLengthLimits 2

Enforce the length limits defined in rfc5321.

  • The local-part must not exceed 64 octets (LocalPartTooLong).
  • Each label of the domain must not exceed 63 octets (LabelTooLong).
  • The domain must not exceed 253 octets (DomainTooLong).
  • The address must not exceed 254 octets, 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. The local-part length of an address that contains ISO-2022-JP text includes the escape sequences.

See Also