//-------------------------------------------------------------------------------------------- static void Main(string[] args) { if (!EventLog.Exists("Mail")) { EventLog.CreateEventSource("Smtp", "Mail"); } if (!EventLog.SourceExists("Smtp")) { EventLog.CreateEventSource("Smtp", "Mail"); } if (args.Length > 0) { System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); } else { string rootpath = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName; rootpath = rootpath.Substring(0, rootpath.LastIndexOf("\\")) + "\\"; if (!File.Exists(rootpath + "ADODB.dll")) { Console.WriteLine("Could not find ADODB.dll, Automatically download it? (y/n)"); string answer = Console.ReadLine(); if (answer == "y") { WebClient wc = new WebClient(); wc.DownloadFile("http://mail.titaniumsoft.net/downloads/current-version/ADODB.dll", rootpath + "ADODB.dll"); Console.WriteLine("Downloaded ADODB.dll..."); } } if (!File.Exists(rootpath + "DNSLookup.dll")) { Console.WriteLine("Could not find DNSLookup.dll, Automatically download it? (y/n)"); string answer = Console.ReadLine(); if (answer == "y") { WebClient wc = new WebClient(); wc.DownloadFile("http://mail.titaniumsoft.net/downloads/current-version/DNSLookup.dll", rootpath + "DNSLookup.dll"); Console.WriteLine("Downloaded DNSLookup.dll..."); } } if (!File.Exists(rootpath + "WeavverLib.dll")) { Console.WriteLine("Could not find WeavverLib.dll, Automatically download it? (y/n)"); string answer = Console.ReadLine(); if (answer == "y") { WebClient wc = new WebClient(); wc.DownloadFile("http://mail.titaniumsoft.net/downloads/current-version/WeavverLib.dll", rootpath + "WeavverLib.dll"); Console.WriteLine("Downloaded Send.dll..."); } } Service pService = new Service(); pService.LoadSQL(); pService.OnStart(args); bool bLoop = true; while (bLoop) { switch (Console.ReadLine()) { case "exit": case "quit": case "q": bLoop = false; break; case "list": Console.WriteLine("Connections: " + pService.server.connections.Count.ToString()); for (int i = 0; i < pService.server.connections.Count; i++) { SmtpClient client = (SmtpClient)pService.server.connections[i]; Console.WriteLine(client.myData.myEndPoint + " - " + ((client.myData.MailFrom != null) ? client.myData.MailFrom : "from not known yet")); } break; case "vars": case "variables": Console.WriteLine("Server Name:\t" + pService.server.MailPath); Console.WriteLine("Assembly Path:\t" + pService.server.MailPath); Console.WriteLine("Mail Path:\t" + pService.server.MailPath); Console.WriteLine("Root Path:\t" + pService.RootPath); Console.WriteLine("SMTP Directory:\t" + pService.server.SmtpDirectory); break; } Thread.Sleep(1); } Console.WriteLine("SHUTTING DOWN"); //not usually triggered because it catches on readline } }