Hossein
Hossein

Reputation: 25924

How can i validate an email address and password is correct in asp.net?

I am trying to send emails using Yahoo or Gmail. Prior to that i want to check if the username and password combination of the email address i am using to send mails is ok and then send the email.
How can i achieve such a thing in Asp.net/C#?
Is there a way to find about the status of the sent email ? (delivered or failed?)

Upvotes: 0

Views: 1446

Answers (2)

Alexander
Alexander

Reputation: 2477

SmtpClient does not offer functions for testing credentials, e.g. just logging in without sending. So the .Net onboard way would be, as previously suggested, to Try/Catch your sending attempt.

If you insist on checking the credentials first, you'd have to implement the SMTP protocol, or parts of it, on your own, using .Net.Sockets.TcpClient. That way you could log on to the SMTP without sending anything.

Upvotes: 1

Ilkka
Ilkka

Reputation: 306

It is possible to receive a so called NDR (Non-Delivery Report/Receipt), but since that is an email sent back to your designated bounce address, you would have to build an application to read those reports as a background process or similar. There is no guarantee that you will get an NDR.

I don't really see the point of checking username/password prior to sending. You would add error handling anyways, so it either fails or succeeds.

Upvotes: 1

Related Questions