System.Net.Mail.SmtpClient.EnableSsl Property

Specify whether the System.Net.Mail.SmtpClient uses Secure Sockets Layer (SSL) to encrypt the connection.

Syntax

public bool EnableSsl { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

The SmtpClient.EnableSsl property specifies whether SSL is used to access the specified SMTP mail server.

The default value for this property can also be set in a machine or application configuration file. Any changes made to the SmtpClient.EnableSsl property override the configuration file settings.

The System.Net.Mail.SmtpClient class only supports the SMTP Service Extension for Secure SMTP over Transport Layer Security as defined in RFC 3207. In this mode, the SMTP session begins on an unencrypted channel, then a STARTTLS command is issued by the client to the server to switch to secure communication using SSL. See RFC 3207 published by the Internet Engineering Task Force (IETF) for more information.

An alternate connection method is where an SSL session is established up front before any protocol commands are sent. This connection method is sometimes called SMTP/SSL, SMTP over SSL, or SMTPS and by default uses port 465. This alternate connection method using SSL is not currently supported.

You can use SmtpClient.ClientCertificates to specify which client certificates should be used to establish the SSL connection. The System.Net.ServicePointManager.ServerCertificateValidationCallback allows you to reject the certificate provided by the SMTP server. The System.Net.ServicePointManager.SecurityProtocol property allows you to specify the version of the SSL protocol to use.

Note:

If the SmtpClient.EnableSsl property is set to true, and the SMTP mail server does not advertise STARTTLS in the response to the EHLO command, then a call to the erload:System.Net.Mail.SmtpClient.Send or erload:System.Net.Mail.SmtpClient.SendAsync methods will throw an System.Net.Mail.SmtpException.

Requirements

Namespace: System.Net.Mail
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0