Click or drag to resize
MimeKit

SmtpClient Constructor

Initializes a new instance of the SmtpClient class.

Namespace: MailKit.Net.Smtp
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
public SmtpClient()
Remarks
Before you can send messages with the SmtpClient, you must first call one of the Connect methods. Depending on whether the SMTP server requires authenticating or not, you may also need to authenticate using one of the Authenticate methods.
Example
C#
public static void SendMessages (IList<MimeMessage> messages)
{
    using (var client = new SmtpClient ()) {
        client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);

        client.Authenticate ("username", "password");

        foreach (var message in messages) {
            client.Send (message);
        }

        client.Disconnect (true);
    }
}
See Also