Can I test SmtpClient before calling client.Send()?

前端 未结 6 776
夕颜
夕颜 2020-11-28 10:58

This is related to a question I asked the other day on how to send email.

My new, related question is this... what if the user of my application is behind a firew

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 11:50

    I also had this need.

    Here's the library I made (it send a HELO and checks for a 200, 220 or 250):

    using SMTPConnectionTest;
    
    if (SMTPConnection.Ok("myhost", 25))
    {
       // Ready to go
    }
    
    if (SMTPConnectionTester.Ok()) // Reads settings from  in .config
    {
        // Ready to go
    }
    

提交回复
热议问题