simple.mailserver
simple.mailserver copied to clipboard
Way to stop the server or bind
I have been looking for a way to stop the listening port without coming out of the console app Is there something built in that I am missing or would I have to make a function to do this.
Indeed this is hard to achieve. I should add some functionality to do that.
For now this could be a workaround:
// ...
smtpServer.BindAndListenTo(IPAddress.Loopback, 25);
// ...
// undo the binding from above
PortListener portListener;
if (smtpServer.Bindings.TryTake(out portListener))
{
portListener.StopListen();
}
// ...