Esempio n. 1
0
 protected void StopSmtpHost()
 {
     if (_smtpHost != null)
     {
         _smtpHost.Stop();
         _smtpHost.Dispose();
         _smtpHost = null;
     }
 }
Esempio n. 2
0
        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();
            }
        }