3

I had web application that users can set SMTP server information (server/host, SMTP Port, Username, Password, EmailAddress, usedSSL). i need when user set information validatre server without sending email and check Is smtp information valid or not?

I found website that works perfect and check is SMTP server alive (but not authentication check).. http://mxtoolbox.com/diagnostic.aspx

Edit 1:

Tanx @Dieter DHoker help me to find Testing SMTP server is running via C# in comments...

Is there anyway that i check authentication information (username & password & email address) as i need to check all smtp information is valid or not? that i asked before..

Community
  • 1
  • 1
Mehdi Yeganeh
  • 2,019
  • 2
  • 24
  • 42
  • You can use the `System.Net` [`Socket`](http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx) class to see if the server responds. – Dustin Kingen Jun 26 '13 at 11:58
  • @Romoku tanx, i know how can i use socket for checking smtp server but i should know about smtp protocol and requests & responses .. and i don`t know about smtp protocol enough.. – Mehdi Yeganeh Jun 26 '13 at 12:01
  • 2
    See: [http://stackoverflow.com/questions/1633391/testing-smtp-server-is-running-via-c-sharp][1] [1]: http://stackoverflow.com/questions/1633391/testing-smtp-server-is-running-via-c-sharp – Dieter DHoker Jun 26 '13 at 12:02
  • 1
    @Dieter DHoker, tanx a lot, i forward 1 step to my perfect answer.. but is there anyway to check user authentication information is right? – Mehdi Yeganeh Jun 26 '13 at 12:05

1 Answers1

-1

There's no username and password in SMTP (see rfc 821), so there's no way to test that. You could use a MAIL FROM and RCPT TO sequence, but not send any DATA, to see if you'll be allowed to send mail with the given information, without sending an actual mail.

Pruyque
  • 372
  • 1
  • 5
  • In `System.Mail.SmtpClient` have Credentials and i can set `smtpClient.Credentials = new System.Net.NetworkCredential(username, password)`, and i should set username & password for sending email from gmail or yahoo .. maybe there is no authentication information in SMTP protocol but i think maybe it used extended protocol or something else that match with SMTP, i test it before and i send email with empty title and empty body ( once test empty rcpt to) but in my test i used `gmail` that get all emails & give me error for empty rcpt to.. – Mehdi Yeganeh Jun 26 '13 at 12:53