コード例 #1
0
        protected override void OnStart(string[] args)
        {
            RabbitMqInboundStagingHandler.Start();

            Logging.Info("Starting Manta MTA Service.");

            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e)
            {
                Exception ex = (Exception)e.ExceptionObject;
                Logging.Fatal(ex.Message, ex);
            };

            // Start the RabbitMQ Bulk inserter.
            QueueManager.Instance.Start();

            VirtualMTACollection ipAddresses = VirtualMtaManager.GetVirtualMtasForListeningOn();

            // Create the SmtpServers
            for (int c = 0; c < ipAddresses.Count; c++)
            {
                VirtualMTA ipAddress = ipAddresses[c];
                for (int i = 0; i < MtaParameters.ServerListeningPorts.Length; i++)
                {
                    _SmtpServers.Add(new SmtpServer(ipAddress.IPAddress, MtaParameters.ServerListeningPorts[i]));
                }
            }

            // Start the SMTP Client.
            MessageSender.Instance.Start();

            // Start the events (bounce/abuse) handler.
            EventsFileHandler.Instance.Start();

            Logging.Info("Manta MTA Service has started.");
        }
コード例 #2
0
        protected override void OnStart(string[] args)
        {
            Logging.Info("Starting OpenManta Service.");
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e)
            {
                Exception ex = (Exception)e.ExceptionObject;
                Logging.Fatal(ex.Message, ex);
            };

            RabbitMqInboundStagingHandler.Start();

            // Start the RabbitMQ Bulk inserter.
            QueueManager.Instance.Start();

            // Create the SmtpServers
            foreach (var vmta in VirtualMtaManager.GetVirtualMtasForListeningOn())
            {
                foreach (var port in MtaParameters.ServerListeningPorts)
                {
                    SmtpServers.Add(new SmtpServer(vmta.IPAddress, port));
                }
            }

            // Start the SMTP Client.
            MessageSender.Instance.Start();

            // Start the events (bounce/abuse) handler.
            EventsFileHandler.Instance.Start();

            Logging.Info("OpenManta Service has started.");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ecruz1994/MantaMTA
        static void Main(string[] args)
        {
            Logging.Info("MTA Started");

            AppDomain.CurrentDomain.FirstChanceException += delegate(object sender, FirstChanceExceptionEventArgs e)
            {
                Logging.Warn("", e.Exception);
            };

            IList <VirtualMTA> ipAddresses = VirtualMtaManager.GetVirtualMtasForListeningOn();

            // Array will hold all instances of SmtpServer, one for each port we will be listening on.
            List <SmtpServer> smtpServers = new List <SmtpServer>();

            // Create the SmtpServers
            for (int c = 0; c < ipAddresses.Count; c++)
            {
                VirtualMTA ipAddress = ipAddresses[c];
                for (int i = 0; i < MtaParameters.ServerListeningPorts.Length; i++)
                {
                    smtpServers.Add(new SmtpServer(ipAddress.IPAddress, MtaParameters.ServerListeningPorts[i]));
                }
            }

            // Start the SMTP Client.
            MessageSender.Instance.Start();
            // Start the events (bounce/abuse) handler.
            EventsFileHandler.Instance.Start();

            QueueManager.Instance.Start();
            OpenManta.Framework.RabbitMq.RabbitMqInboundStagingHandler.Start();

            bool quit = false;

            while (!quit)
            {
                ConsoleKeyInfo key = System.Console.ReadKey(true);
                if (key.KeyChar == 'q' || key.KeyChar == 'Q')
                {
                    quit = true;
                }
            }

            // Need to wait while servers & client shutdown.
            MantaCoreEvents.InvokeMantaCoreStopping();
            foreach (SmtpServer s in smtpServers)
            {
                s.Dispose();
            }

            Logging.Info("MTA Stopped");
            System.Console.WriteLine("Press any key to continue");
            System.Console.ReadKey(true);
        }