1

SMTP connection is validated by sending mail like in below.

SmtpClient client = new SmtpClient(host);
client.Credentials = new NetworkCredential(username,password);
client.UseDefaultCredentials = false;
client.Send(mail);

But we need to validate the SMTP credentials(Host,Port,Username,Password) without sending the mail.

Is there any way to achieve this by programmatically?

christo
  • 129
  • 1
  • 2
  • 13

1 Answers1

0

You can catch the SmtpException which triggered with the below reasons,

  1. The connection to the SMTP server failed.
  2. Authentication failed.
  3. EnableSsl is set to true but the DeliveryMethod property is set to
  4. SpecifiedPickupDirectory or PickupDirectoryFromIis. EnableSsl is set to true, but the SMTP mail server did not advertise STARTTLS in theresponse to the EHLO command.

Or you can write a separate validation class as describe in this link

SilentCoder
  • 1,970
  • 1
  • 16
  • 21