Aspose Email for .Net. Check SMTP connection without sending the mail

Hello!

We are planning to use Email for .Net. Now I am investigating Aspose library. I can’t find a way to test SMTP connection without sending the email. Please advise. I want to check that username/pass are valid without sending the email.

Thank you,
Igor

@iga1

The API does support working with SMTP. Please visit this documentation link for your kind reference.

Hello!

I have found documentation, but I can’t understand how can I check connection (including name and password) to the SMTP server without sending the email. If I use CreateConnection method then i do not get any error about incorrect username/password. In our application we at first configure application and we have a “Test” button. Pressing this button we check that SMPT server is available and that credentials are correct. How can I implement this functionality.

Thank you,
Igor

@iga1

You can create client with credentials and then execute client.Noop() when you want to check connection. Actually connection has to be auto-restored in case if it was broken.

using (SmtpClient client = new SmtpClient(
                "server.SmtpUrl",
                587,
                "user.EMail",
                "user.Password"))
            {
                client.Noop();
                client.Noop();
                client.Noop();
                client.Noop();
                client.Noop();
                client.Noop();
            }

Hello,
I tried the following code:

Dim client As SmtpClient = New SmtpClient()
Try
client.Host = “smtp.gmail.com”
client.Port = 587
client.Username = “userName”
client.Password = “Password”
client.SecurityOptions = SecurityOptions.SSLExplicit


        client.Noop()
    Catch ex As Exception
        MessageBox.Show("Error" + ex.Message)
        Return
    End Try
	
	MessageBox.Show("Connected")

but I don’t see any exception if credentials are incorrect. Please advise.

Thank you,
Igor

@iga1

From your last message, it seems that you are looking for option to verify the user credentials using SMTP without sending or forwarding email. If this is requirement, then at the moment there is no other option to validate the credentials then by sending an email using credentials over SMTP. I have created a ticket with ID EMAILNET-40001 in our issue tracking system as new feature request to provide the support for validating the credentials using SMTP without sending email. We will share the feedback with you as soon as the support will be available in API.

The issues you have found earlier (filed as EMAILNET-40001) have been fixed in this update.