Click or drag to resize
MimeKit

SmtpCapabilities Enumeration

Capabilities supported by an SMTP server.

Namespace: MailKit.Net.Smtp
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
[FlagsAttribute]
public enum SmtpCapabilities
Members
Member nameValueDescription
None0 The server does not support any additional extensions.
Size1 The server supports the SIZE extension and may have a maximum message size limitation (see MaxSize).
Dsn2 The server supports the DSN extension, allowing clients to specify which (if any) recipients they would like to receive delivery notifications for.
EnhancedStatusCodes4 The server supports the ENHANCEDSTATUSCODES extension.
Authentication8 The server supports the AUTH extension, allowing clients to authenticate via supported SASL mechanisms.
EightBitMime16 The server supports the 8BITMIME extension, allowing clients to send messages using the "8bit" Content-Transfer-Encoding.
Pipelining32 The server supports the PIPELINING extension, allowing clients to send multiple commands at once in order to reduce round-trip latency.
BinaryMime64 The server supports the BINARYMIME extension.
Chunking128 The server supports the CHUNKING extension, allowing clients to upload messages in chunks.
StartTLS256 The server supports the STARTTLS extension, allowing clients to switch to an encrypted SSL/TLS connection after connecting.
UTF8512 The server supports the SMTPUTF8 extension.
RequireTLS1,024 The server supports the REQUIRETLS extension.
Remarks
Capabilities are read as part of the response to the EHLO command that is issued during the connection phase of the SmtpClient.
Example
C#
public static void PrintCapabilities ()
{
    using (var client = new SmtpClient ()) {
        client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);

        if (client.Capabilities.HasFlag (SmtpCapabilities.Authentication)) {
            var mechanisms = string.Join (", ", client.AuthenticationMechanisms);
            Console.WriteLine ("The SMTP server supports the following SASL mechanisms: {0}", mechanisms);
            client.Authenticate ("username", "password");
        }

        if (client.Capabilities.HasFlag (SmtpCapabilities.Size))
            Console.WriteLine ("The SMTP server has a size restriction on messages: {0}.", client.MaxSize);

        if (client.Capabilities.HasFlag (SmtpCapabilities.Dsn))
            Console.WriteLine ("The SMTP server supports delivery-status notifications.");

        if (client.Capabilities.HasFlag (SmtpCapabilities.EightBitMime))
            Console.WriteLine ("The SMTP server supports Content-Transfer-Encoding: 8bit");

        if (client.Capabilities.HasFlag (SmtpCapabilities.BinaryMime))
            Console.WriteLine ("The SMTP server supports Content-Transfer-Encoding: binary");

        if (client.Capabilities.HasFlag (SmtpCapabilities.UTF8))
            Console.WriteLine ("The SMTP server supports UTF-8 in message headers.");

        client.Disconnect (true);
    }
}
See Also