Exemplo n.º 1
0
        public static void EmailModuleSample()
        {
            // Configuring smtp server
            var smtpServerConfiguration = new SmtpServerConfiguration("userName", "password", "smtp.gmail.com", 587);

            // Creating a module
            var emailSenderLoggerModule = new EmailSenderLoggerModule(smtpServerConfiguration)
            {
                EnableSsl = true,
                Sender    = "*****@*****.**"
            };

            // Add the module and it works
            emailSenderLoggerModule.Recipients.Add("*****@*****.**");

            //  // Simulation of exceptions
            Logger.Modules.Install(emailSenderLoggerModule);

            try
            {
                // Simulation of exceptions
                throw new NullReferenceException();
            }
            catch (Exception exception)
            {
                // Log exception
                // If you catch an exception error -> will be sent an email with a list of log message.
                Logger.Log(exception);
            }
        }
Exemplo n.º 2
0
        private static SmtpServerConfiguration CreateWithConfigurationChangedEvent(Action onChangedDelegate)
        {
            var config = new SmtpServerConfiguration();

            config.ConfigurationChanged += c => onChangedDelegate();
            return(config);
        }
Exemplo n.º 3
0
        public SmtpServer()
        {
            Bindings      = new ConcurrentBag <PortListener>();
            Connections   = new ConcurrentDictionary <EndPoint, SmtpConnection>();
            Configuration = new SmtpServerConfiguration();
            Watchdog      = new IdleConnectionDisconnectWatchdog <SmtpServer>(this);

            WatchForConfigurationChange();
        }