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.
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.
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();
}
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.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.