Click or drag to resize
MimeKit

SmtpClientCapabilities Property

Get the capabilities supported by the SMTP server.

Namespace:  MailKit.Net.Smtp
Assembly:  MailKit (in MailKit.dll) Version: 2.3.0
Syntax
C#
public SmtpCapabilities Capabilities { get; set; }

Property Value

Type: SmtpCapabilities
The capabilities.
Exceptions
ExceptionCondition
ArgumentException Capabilities cannot be enabled, they may only be disabled.
Remarks
The capabilities will not be known until a successful connection has been made and may change once the client is authenticated.
Examples
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