How can I test SMTP is up and running via C# without sending a message.
I could of course try:
try{
// send email to "nonsense@example.com"
}
catch
{
// log "smtp is down"
}
There must be a more tidy way to do this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can try saying
EHLOto your server and see if it responds with250 OK. Of course this test doesn’t guarantee you that you will succeed sending the mail later, but it is a good indication.And here’s a sample:
And here’s the list of codes to expect.