Utility Features - SMTP Client

Utility Features - SMTP Client

Listing Extension Servers using Smtp Client

Aspose.Email SmtpClient lets you retrieve the server extensions that a server supports such as IDLE, UNSELECT, QUOTA, etc. This helps in identifying the availability of an extension before using the client for that particular functionality. The GetCapabilities() method returns the supported extension types in the form of a string array.

Retrieving Server Extensions

The following code snippet shows you how to retrieve server extensions.

Working with Signed Message

Aspose.Email API provides the capability to create Signed messages using certificates. The AttachSignature method of the MailMessage class can be used to sign a message for saving or even sending it using the SmtpClient.

Sign a Message

The following code snippet shows you how to Sign a Message.

Using Detached Certificate Option

Web-based email clients may not be able to display body contents of a Signed message. This can be taken care of by detaching the certificate before sending it to web-based email clients. The detached flag in the overloaded method of AttachSignature can be used to achieve this. If set to true, the certificate is detached from the email and vice versa. To see Signed Message body in Web-based clients, you need to create MailMessage with detached signature. The following code snippet shows you how to use detached certificate option.

Validate Mail Server Credentials Without Sending Email

Aspose.Email API provides the capability to validate mail server credentials without sending an email. It can be achieved with the ValidateCredentials method which is responsible for verifying the authenticity and correctness of the provided email credentials, which are normally used for authentication when connecting to the server.

It verifies that the provided email credentials, such as username and password, are valid, and that the client can establish a successful connection to the server. This verification of credentials helps ensure that the customer can access the email account securely and perform various operations, such as sending email.

using (SmtpClient client = new SmtpClient(server.SmtpUrl, server.SmtpPort, "username", "password", SecurityOptions.Auto))
{
    client.Timeout = 4000;
   
    if (client.ValidateCredentials())
    {
        //to do something
    }
}

There is also a version of the method ValidateCredentialsAsync to perform an asynchronous operation.