protected void StopSmtpHost() { if (_smtpHost != null) { _smtpHost.Stop(); _smtpHost.Dispose(); _smtpHost = null; } }
protected void StartSmtpHost() { if (_smtpHost == null) { var credentials = this.Config.EnableSMTPAuth ? this.Config.Accounts.Select(a => a.ToNetworkCredential()) : Enumerable.Empty <NetworkCredential>(); _smtpHost = new SmtpServerCore( this.Config.SmtpEndPoints.Select(ep => ep.ToIPEndPoint()), credentials); _smtpHost.ReceiveMessage += OnReceiveMessage; _smtpHost.Start(); } }