Example #1
0
        public void TestStartTransactionValidationSuccess()
        {
            var core = new SMTPServer(DefaultLoader());

            var ip = IPAddress.Parse("127.0.0.1");

            SMTPTransaction actualTransaction = null;
            IPAddress       actualIP          = null;

            core.OnConnect += (transaction, args) =>
            {
                actualTransaction = transaction;
                actualIP          = args.IP;
            };

            SMTPTransaction expectedTransaction;
            SMTPResponse    reponse;

            using (ShimsContext.Create())
            {
                var settings = new StubIReceiveSettings();

                expectedTransaction = core.StartTransaction(ip, settings, out reponse);
            }

            Assert.Equal(SMTPStatusCode.Ready, reponse.Code);
            Assert.Same(expectedTransaction, actualTransaction);
            Assert.Same(ip, actualIP);
        }
Example #2
0
        public void TestStartTransactionValidationFail(SMTPStatusCode?code)
        {
            var core = new SMTPServer(DefaultLoader());

            var ip = IPAddress.Parse("127.0.0.1");

            using (ShimsContext.Create())
            {
                var closed = false;
                ShimSMTPTransaction.AllInstances.Close = transaction => { closed = true; };

                core.OnConnect += (transaction, args) =>
                {
                    args.Cancel       = true;
                    args.ResponseCode = code;
                };

                SMTPResponse reponse;
                using (ShimsContext.Create())
                {
                    var settings = new StubIReceiveSettings();

                    core.StartTransaction(ip, settings, out reponse);
                }

                Assert.Equal(code ?? SMTPStatusCode.TransactionFailed, reponse.Code);
                Assert.True(closed);
            }
        }
Example #3
0
        public void TestHandlers()
        {
            var        initialized = false;
            SMTPServer actualCore  = null;

            var handler = new StubICommandHandler
            {
                InitializeSMTPServer = c =>
                {
                    actualCore  = c;
                    initialized = true;
                }
            };

            var loader = new StubICommandHandlerLoader
            {
                GetModules = () => new List <Tuple <string, ICommandHandler> >
                {
                    new Tuple <string, ICommandHandler>("Test", handler)
                }
            };

            var core = new SMTPServer(loader);

            Assert.Same(core, actualCore);
            Assert.True(initialized);

            var actualHandler = core.GetHandler("Test");

            Assert.Same(handler, actualHandler);

            var nonExistant = core.GetHandler("NonExistant");

            Assert.Null(nonExistant);
        }
Example #4
0
        public void TestStartTransaction()
        {
            const string     banner         = "Test Banner";
            IReceiveSettings actualSettings = null;

            var core = new SMTPServer(DefaultLoader());

            var ip = IPAddress.Parse("127.0.0.1");

            using (ShimsContext.Create())
            {
                var expectedSettings = new StubIReceiveSettings
                {
                    BannerGet = () => banner
                };

                SMTPServer actualCore = null;

                ShimSMTPTransaction.ConstructorSMTPServerIReceiveSettings = (transaction, smtpCore, settings) =>
                {
                    actualSettings = settings;
                    actualCore     = smtpCore;
                };

                SMTPResponse reponse;
                core.StartTransaction(ip, expectedSettings, out reponse);

                Assert.Equal(SMTPStatusCode.Ready, reponse.Code);
                Assert.Equal(banner, reponse.Args[0]);
                Assert.Same(core, actualCore);
                Assert.Same(expectedSettings, actualSettings);
            }
        }
Example #5
0
        public override void Initialize(SMTPServer server)
        {
            base.Initialize(server);

            server.GetListProperty <Func <SMTPTransaction, string> >("EHLOLines")
            .Add(transaction => transaction.TLSActive || !transaction.Settings.EnableTLS ? null : "STARTTLS");
        }
Example #6
0
        public void TestSetAndGetProperty()
        {
            var core = new SMTPServer(DefaultLoader());

            const int    value1 = 5;
            const string value2 = "foo";
            const bool   value3 = false;
            var          value4 = new object();

            core.SetProperty("foo", value1);
            var actualValue1 = core.GetProperty <int>("foo");

            Assert.Equal(value1, actualValue1);

            core.SetProperty("foo", value2);
            var actualValue2 = core.GetProperty <string>("foo");

            Assert.Equal(value2, actualValue2);

            core.SetProperty("foo", value3);
            var actualValue3 = core.GetProperty <bool>("foo");

            Assert.Equal(value3, actualValue3);

            core.SetProperty("foo", value4);
            var actualValue4 = core.GetProperty <object>("foo");

            Assert.Equal(value4, actualValue4);
        }
Example #7
0
        public void TestTriggerNewMessage()
        {
            var core     = new SMTPServer(DefaultLoader());
            var settings = new StubIReceiveSettings();

            var expectedTransaction = new StubSMTPTransaction(core, settings);
            var expectedSender      = new MailPath("tester", "test.de");
            var expectedRecipients  = new[] { new MailPath("fubar", "fu.com") };
            var expectedBody        = "Test";

            SMTPTransaction actualTransaction = null;
            Mail            actualMail        = null;
            var             triggered         = false;

            core.OnNewMessage += (transaction, mail) =>
            {
                triggered         = true;
                actualTransaction = transaction;
                actualMail        = mail;
            };

            core.TriggerNewMessage(expectedTransaction, expectedSender, expectedRecipients, expectedBody);

            // TODO: Remove dependencies of test

            Assert.True(triggered);
            Assert.Equal(expectedTransaction, actualTransaction);
            Assert.Equal(expectedSender.ToMailAdress(), actualMail.From);
            Assert.Equal(expectedRecipients.Select(r => r.ToMailAdress().ToString()).ToArray(),
                         actualMail.Recipients.Select(r => r.ToString()).ToArray());
            Assert.Equal(expectedBody, actualMail.Body);
        }
Example #8
0
        public void TestGetNonExistantProperty()
        {
            var core = new SMTPServer(DefaultLoader());

            Assert.Equal(default(int), core.GetProperty <int>("nonExistant"));
            Assert.Equal(default(bool), core.GetProperty <bool>("nonExistant"));
            Assert.Equal(default(string), core.GetProperty <string>("nonExistant"));
        }
Example #9
0
        public SendMail(IConfiguration config)
        {
            _smtpServer = new SMTPServer();

            new ConfigureFromConfigurationOptions <SMTPServer>(
                config.GetSection("SMTPServer"))
            .Configure(_smtpServer);
        }
Example #10
0
        public SMTPSimulatorService()
        {
            Logger.Info("The SMTPSimulator is starting...");

            FixLoggerPaths();
            InitializeDataDirectory();
            InitializeComponent();

            var pluginFolder = ConfigurationManager.AppSettings["PluginFolder"];

            ComposablePartCatalog catalog;

            if (!string.IsNullOrEmpty(pluginFolder))
            {
                catalog = new AggregateCatalog(
                    new AssemblyCatalog(typeof(SMTPSimulatorService).Assembly),
                    new DirectoryCatalog(AssemblyDirectory),
                    new DirectoryCatalog(pluginFolder)
                    );
            }
            else
            {
                catalog = new AggregateCatalog(
                    new AssemblyCatalog(typeof(SMTPSimulatorService).Assembly),
                    new DirectoryCatalog(AssemblyDirectory)
                    );
            }

            _container = new CompositionContainer(catalog);
            _container.ComposeExportedValue(_container);
            _container.SatisfyImportsOnce(this);

            var loader = new CommandHandlerLoader(catalog);

            _smtpServer = new SMTPServer(loader);

            foreach (var tt in _timeTables.All())
            {
                var generator = new TimeTableGenerator(tt, _mailQueue, _container);
                _generators.Add(tt.Id, generator);

                if (tt.Active)
                {
                    generator.Start();
                }
            }

            _timeTables.OnTimeTableAdd    += OnTimeTableAdd;
            _timeTables.OnTimeTableRemove += OnTimeTableRemove;

            _retentionManager = new RetentionManager();

            RefreshServers();
            RefreshSenders();

            Logger.Info("The SMTPSimulator Service has started.");
        }
Example #11
0
 public MailSenderService(Sender sender, SMTPServer server)
 {
     this.host       = server.Address;
     this.port       = server.Port;
     this.user_email = sender.Email;
     this.user_name  = sender.Login;
     this.password   = sender.Password;
     this.message    = "не указан текст";
     this.subject    = "не указана тема";
 }
Example #12
0
        public override void Initialize(SMTPServer server)
        {
            base.Initialize(server);

            if (_authMethods.Any())
            {
                var methods = string.Join(" ", _authMethods.Keys);

                server.GetListProperty <Func <SMTPTransaction, string> >("EHLOLines").Add(transaction => "AUTH " + methods);
            }
        }
Example #13
0
        public void TestHasProperty()
        {
            var core = new SMTPServer(DefaultLoader());

            Assert.False(core.HasProperty("foo"));

            core.SetProperty("foo", 5);
            Assert.True(core.HasProperty("foo"));

            core.SetProperty("foo", null);
            Assert.False(core.HasProperty("foo"));
        }
Example #14
0
        private void btnTestEmail_Click(object sender, EventArgs e)
        {
            Quiksoft.EasyMail.SMTP.License.Key = "Muroc Systems, Inc. (Single Developer)/9983782F406978487783FBAA248A#E86A";
            Quiksoft.EasyMail.SSL.License.Key  = "Muroc Systems, Inc. (Single Developer)/9984652F406991896501FC33B3#02AE4B";

            const string smtpServerHostName = "smtp.socketlabs.com";
            const string smtpUserName       = "******";
            const string smtpPassword       = "******";

            var ssl  = new Quiksoft.EasyMail.SSL.SSL();
            var smtp = new Quiksoft.EasyMail.SMTP.SMTP();


            EmailMessage msg = new EmailMessage();

            msg.Recipients.Add("*****@*****.**", "Kevin Tst Jones", RecipientType.To);
            msg.Subject    = "KEVIN'S TEST EMAIL";
            msg.From.Email = "*****@*****.**";
            msg.From.Name  = "Mr. blah";
            msg.BodyParts.Add(new Quiksoft.EasyMail.SMTP.BodyPart("三菱電機 増田です。", BodyPartFormat.HTML));
            msg.CharsetEncoding = System.Text.Encoding.UTF8;
            //msg.Attachments.Add("c:\\tesxt.png");
            msg.CustomHeaders.Add("X-xsMessageId", "");
            msg.CustomHeaders.Add("X-xsMailingId", "");
            //message.Headers.Add("X-xsMessageId", email.OrganizationID.ToString());
            //message.Headers.Add("X-xsMailingId", email.EmailID.ToString());

            //Set the SMTP server and secure port.
            var smtpServer = new SMTPServer
            {
                Name     = smtpServerHostName,
                Port     = 465, //Secure port
                Account  = smtpUserName,
                Password = smtpPassword,
                AuthMode = SMTPAuthMode.AuthLogin
            };

            smtp.SMTPServers.Add(smtpServer);

            try
            {
                smtp.Connect(ssl.GetInterface());
                //For performance loop here to send multiple message on the same connection.
                smtp.Send(msg);
                //Disconnect when done.
                smtp.Disconnect();
                MessageBox.Show("Message Sent");
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error sending mail\n\n" + ex.Message);
            }
        }
Example #15
0
        private void SendEmail(string subject, string body)
        {
            const int DefaultSMTPPort = 25;

            if (string.IsNullOrEmpty(SMTPServer))
            {
                Log.Error("Email failed to send.  SMTPServer field is either null or empty");
                return;
            }

            string[] smtpServerParts = SMTPServer.Split(':');
            string   host            = smtpServerParts[0];
            int      port;

            if (smtpServerParts.Length <= 1 || !int.TryParse(smtpServerParts[1], out port))
            {
                port = DefaultSMTPPort;
            }

            using (SmtpClient smtpClient = new SmtpClient(host, port))
                using (MailMessage emailMessage = new MailMessage())
                {
                    if (!string.IsNullOrEmpty(Username) && (object)SecurePassword != null)
                    {
                        smtpClient.Credentials = new NetworkCredential(Username, SecurePassword);
                    }

                    smtpClient.EnableSsl = EnableSSL;

                    emailMessage.From       = new MailAddress(FromAddress);
                    emailMessage.Subject    = subject;
                    emailMessage.Body       = body;
                    emailMessage.IsBodyHtml = true;

                    // Add the specified To recipients for the email message
                    if (AdminAddress.Contains(","))
                    {
                        foreach (string address in AdminAddress.Split(','))
                        {
                            emailMessage.To.Add(address);
                        }
                    }
                    else
                    {
                        emailMessage.To.Add(AdminAddress);
                    }

                    // Send the email
                    smtpClient.Send(emailMessage);
                }
        }
Example #16
0
        public void Construct_GivenNoParameters_ShouldNotThrow()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            SMTPServer server = null;
            Assert.DoesNotThrow(() => server = new SMTPServer());

            //---------------Test Result -----------------------
            Assert.IsInstanceOf<TcpServer>(server);
            Assert.AreNotEqual(0, server.Port);
        }
Example #17
0
        public SMTPService(IReceiveConnector connector, SMTPServer smtpServer, CompositionContainer container)
        {
            _container    = container;
            LocalEndpoint = new IPEndPoint(connector.Address, connector.Port);
            SMTPServer    = smtpServer;

            Connector = connector;
            Settings  = new DefaultReceiveSettings(connector);

            _greylistingManager   = new GreylistingManager(connector.GreylistingTime ?? TimeSpan.Zero);
            SMTPServer.OnConnect += SMTPServerOnOnConnect;

            _container.SatisfyImportsOnce(this);
        }
Example #18
0
        public void Construct_GivenPort_ShouldNotThrow()
        {
            //---------------Set up test pack-------------------
            var port = RandomValueGen.GetRandomInt(1000, 10000);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            SMTPServer server = null;
            Assert.DoesNotThrow(() => server = new SMTPServer(port));

            //---------------Test Result -----------------------
            Assert.IsInstanceOf<TcpServer>(server);
            Assert.AreEqual(port, server.Port);
        }
Example #19
0
        internal Listener(IPAddress address, ushort port, SMTPServer s, bool secure)
        {
            Server           = s;
            _secure          = secure;
            ClientProcessors = new List <ClientProcessor>();

            var ipEndPoint = new IPEndPoint(address, port);

            _listener       = new TcpListener(ipEndPoint);
            _listenerThread = new Thread(Listen)
            {
                Name         = "Listening on port " + port,
                IsBackground = true
            };
        }
Example #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting SMTP server on all IP addresses (both IPv4 and IPv6) on ports:\n- plain: 25, 587\n- TLS: 465");
            Console.WriteLine("Password for all accounts is \"123\".");

            var server = new SMTPServer(new[]
            {
                new ListeningParameters()
                {
                    IpAddress    = IPAddress.Any,
                    RegularPorts = new ushort[] { 25, 587 },
                    TlsPorts     = new ushort[] { 465 }
                },
                new ListeningParameters()
                {
                    IpAddress    = IPAddress.IPv6Any,
                    RegularPorts = new ushort[] { 25, 587 },
                    TlsPorts     = new ushort[] { 465 }
                }
            }, new ServerOptions()
            {
                ServerName = "Test SMTP Server", RequireEncryptionForAuth = false
            }, new DeliveryInterface(), new LoggerInterface());

            //with TLS:
            //}, new ServerOptions() { ServerName = "Test SMTP Server", RequireEncryptionForAuth = true}, new DeliveryInterface(), new LoggerInterface(), new X509Certificate2("PathToCertWithKey.pfx"));

            server.SetAuthLogin(new AuthenticationInterface());
            server.SetFilter(new FilterInterface());
            server.Start();

            Console.WriteLine("Server is running. Type \"exit\" to stop and exit.");

            while (true)
            {
                var read = Console.ReadLine();
                if (read != null && read.ToLower() == "exit")
                {
                    break;
                }
            }

            Console.WriteLine("Stopping the server...");
            server.Dispose();
        }
Example #21
0
        public ConfigurationServiceImpl(SMTPServer server, ISMTPServerContainer servers, IMailQueueProvider mailQueue)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (servers == null)
            {
                throw new ArgumentNullException("servers");
            }
            if (mailQueue == null)
            {
                throw new ArgumentNullException("mailQueue");
            }

            _servers   = servers;
            _mailQueue = mailQueue;
            SmtpServer = server;
        }
Example #22
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                string[]    Addresses = ToBox.Get(context).Split(';');
                MailAddress From      = new MailAddress(FromBox.Get(context), FromName.Get(context));
                MailMessage Message   = new MailMessage();

                foreach (string addr in Addresses)
                {
                    Message.To.Add(addr);
                }

                Message.Subject    = Subject.Get(context);
                Message.Body       = Body.Get(context);
                Message.IsBodyHtml = true;
                Message.From       = From;

                int        SMTP   = Convert.ToInt32(SMTPServer.Get(context));
                SmtpClient Client = new SmtpClient(SMTPServer.Get(context), SMTP);
                Client.Credentials = new NetworkCredential(FromBox.Get(context), MailPassword.Get(context));

                string[] AttachedFiles = Attachments.Get(context);
                if (AttachedFiles.Length > 0)
                {
                    foreach (string file in AttachedFiles)
                    {
                        if (!string.IsNullOrEmpty(file))
                        {
                            Message.Attachments.Add(new Attachment(file));
                        }
                    }
                }

                Client.Send(Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Example #23
0
        public void TestGetListProperty()
        {
            var core = new SMTPServer(DefaultLoader());

            var list = core.GetListProperty <string>("foo");

            Assert.NotNull(list);
            Assert.Empty(list);

            list.Add("fubar");

            list = core.GetListProperty <string>("foo");

            Assert.NotNull(list);
            Assert.Contains("fubar", list);

            core.SetProperty("foo", null);

            list = core.GetListProperty <string>("foo");

            Assert.NotNull(list);
            Assert.Empty(list);
        }
Example #24
0
        /// <summary>
        /// Method to send email
        /// </summary>
        /// <param name="mail">mail details</param>
        /// <param name="setting">smtp server details</param>
        private void SendEmail(EmailServiceDTO mail, SMTPServer setting)
        {
            AspectEnums.EmailStatus mailStatus = AspectEnums.EmailStatus.None;
            SMTPServerDTO           smtpDetail = new SMTPServerDTO();
            Mapper mapper = new Mapper();

            mapper.CreateMap <SMTPServer, SMTPServerDTO>();
            mapper.Map(setting, smtpDetail);
            string remarks = string.Empty;
            //call mathod to send email
            bool isSent = MailingEngine.SendEmail(mail, smtpDetail);

            if (isSent)
            {
                mailStatus = AspectEnums.EmailStatus.Delivered;
                remarks    = "Success";
            }
            else
            {
                mailStatus = AspectEnums.EmailStatus.Failed;
                remarks    = "Failure";
            }
            SystemRepository.UpdateEmailServiceStatus(mail.EmailServiceID, (int)mailStatus, remarks);
        }
Example #25
0
        static void Main(string[] args)
        {
            string logPath = "";

            if (args.Length > 1)
            {
                logPath = args[1].Replace("\"", "");
                if (!logPath.EndsWith("\\"))
                {
                    logPath += "\\";
                }
            }
            string fn  = logPath + DateTime.Now.ToString("yyyyMMdd") + " smtp.log";
            int    nxt = 0;

            while (System.IO.File.Exists(fn))
            {
                nxt++;
                fn = logPath + DateTime.Now.ToString("yyyyMMdd") + nxt.ToString() + " smtp.log";
            }
            System.IO.FileStream fs = new System.IO.FileStream(fn, System.IO.FileMode.Create);
            // First, save the standard output.
            System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);

            sw.WriteLine("Smtp Started");
            if (args.Length > 0)
            {
                sw.WriteLine("ini file: " + args[0]);
                string output = args[0];

                if (System.IO.File.Exists(output))
                {
                    sw.WriteLine("File Found");
                    string line;
                    try
                    {
                        MailMessage MyMailMessage = new MailMessage();
                        System.Net.NetworkCredential nc = new System.Net.NetworkCredential();
                        string sender = "Optimiza", senderaddress = "";

                        //Create the SMTPClient object and specify the SMTP GMail server
                        SmtpClient SMTPServer = new SmtpClient();

                        // Read the file and display it line by line.
                        System.IO.StreamReader file = new System.IO.StreamReader(output);
                        while ((line = file.ReadLine()) != null)
                        {
                            if (line.ToLower().StartsWith("host="))
                            {
                                SMTPServer = new SmtpClient(line.Substring(5));
                            }
                            else if (line.ToLower().StartsWith("port="))
                            {
                                SMTPServer.Port = int.Parse(line.Substring(5));
                            }
                            else if (line.ToLower().StartsWith("user id="))
                            {
                                nc.UserName = line.Substring(8);
                            }
                            else if (line.ToLower().StartsWith("password="******"sender name="))
                            {
                                sender = line.Substring(12);
                            }
                            else if (line.ToLower().StartsWith("sender email="))
                            {
                                senderaddress = line.Substring(13);
                            }
                            else if ((line.ToLower().StartsWith("to=")) && (line.Substring(3).Trim() != ""))
                            {
                                MyMailMessage.To.Add(line.Substring(3));
                            }
                            else if ((line.ToLower().StartsWith("cc=")) && (line.Substring(3).Trim() != ""))
                            {
                                MyMailMessage.CC.Add(line.Substring(3));
                            }
                            else if ((line.ToLower().StartsWith("bcc=")) && (line.Substring(4).Trim() != ""))
                            {
                                MyMailMessage.Bcc.Add(line.Substring(4));
                            }
                            else if (line.ToLower().StartsWith("subject="))
                            {
                                MyMailMessage.Subject = line.Substring(8);
                            }
                            else if (line.ToLower().StartsWith("message="))
                            {
                                MyMailMessage.Body = line.Substring(8).Replace(",", "\n").Replace("\"", "");
                            }
                            else if (line.ToLower().StartsWith("attachments="))
                            {
                                string[] attach = line.Substring(12).Replace("\"", "").Split(',');
                                foreach (var item in attach)
                                {
                                    if (item != "")
                                    {
                                        MyMailMessage.Attachments.Add(new Attachment(item));
                                    }
                                }
                            }
                        }

                        file.Close();
                        MyMailMessage.Sender = new MailAddress(senderaddress, sender);
                        MyMailMessage.From   = new MailAddress(senderaddress, sender);
                        //SMTPServer.Credentials = nc;
                        //SMTPServer.EnableSsl = true;
                        try
                        {
                            sw.WriteLine("Sending");
                            SMTPServer.Send(MyMailMessage);
                            sw.WriteLine("Sent");
                        }
                        catch (SmtpException ex)
                        {
                            sw.WriteLine("error: " + ex.Message);
                        }
                    }
                    catch (SmtpException ex)
                    {
                        sw.WriteLine("error: " + ex.Message);
                    }
                }
            }
            else
            {
                sw.WriteLine("ini file not found?");
            }
            sw.Flush();
            sw.Close();
        }
Example #26
0
        public string Info()
        {
            int           i;
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.Append("QualityPreference: ");
            for (i = 0; i < QualityPreference.Length; i++)
            {
                sb.AppendFormat("{0}   ", QualityPreference[i]);
            }
            sb.AppendLine();
            sb.AppendFormat("{0}: {1}\n", "TrailerDownloadFolder", TrailerDownloadFolder.ToString());
            sb.AppendFormat("{0}: {1}\n", "MetadataDownloadFolder", MetadataDownloadFolder.ToString());
            sb.AppendFormat("{0}: {1}\n", "3DTrailerDownloadFolder", Trailer3DDownloadFolder.ToString());
            sb.AppendFormat("{0}: {1}\n", "3DMetadataDownloadFolder", Metadata3DDownloadFolder.ToString());
            sb.AppendFormat("{0}: {1}\n", "GrabPoster", GrabPoster.ToString());
            sb.AppendFormat("{0}: {1}\n", "CreateFolder", CreateFolder.ToString());
            sb.AppendFormat("{0}: {1}\n", "VerboseLogging", VerboseLogging.ToString());
            sb.AppendFormat("{0}: {1}\n", "PhysicalLog", PhysicalLog.ToString());
            sb.AppendFormat("{0}: {1}\n", "PauseWhenDone", PauseWhenDone.ToString());
            sb.AppendFormat("{0}: {1}\n", "KeepFor", KeepFor.ToString());
            sb.AppendFormat("{0}: {1}\n", "DeleteToRecycleBin", DeleteToRecycleBin.ToString());
            sb.AppendFormat("{0}: {1}\n", "UseExclusions", UseExclusions.ToString());
            sb.AppendFormat("{0}: {1}\n", "TrailersOnly", TrailersOnly.ToString());
            sb.AppendFormat("{0}: {1}\n", "TrailersIdenticaltoTheatricalTrailers", TrailersIdenticaltoTheatricalTrailers.ToString());
            sb.AppendFormat("{0}: {1}\n", "SkipTheatricalTrailers", SkipTheatricalTrailers.ToString());
            sb.AppendFormat("{0}: {1}\n", "SkipTeaserTrailers", SkipTeaserTrailers.ToString());
            sb.AppendFormat("{0}: {1}\n", "ConsiderTheatricalandNumberedTrailersasIdentical", ConsiderTheatricalandNumberedTrailersasIdentical.ToString());
            sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedGenresOnly", IncludeGenres.ToString());
            sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedGenresOnly", ExcludeGenres.ToString());
            sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedLanguagesOnly", IncludeLanguages.ToString());
            sb.AppendFormat("{0}: {1}\n", "MinTrailerSize", MinTrailerSize.ToString());
            sb.AppendFormat("{0}: {1}\n", "AddDates", AddDates.ToString());
            if ((UserAgentId == null) || (UserAgentId.Length == 0))
            {
                sb.AppendLine("No UserAgentId defined");
            }
            else
            {
                for (i = 0; i < UserAgentId.Length; i++)
                {
                    sb.AppendFormat("UserAgendId({0}): {1}\n", i + 1, UserAgentId[i]);
                }
            }
            if ((UserAgentString == null) || (UserAgentString.Length == 0))
            {
                sb.AppendLine("No UserAgentString defined");
            }
            else
            {
                for (i = 0; i < UserAgentString.Length; i++)
                {
                    sb.AppendFormat("UserAgentString({0}): {1}\n", i + 1, UserAgentString[i]);
                }
            }
            sb.AppendFormat("{0}: {1}\n", "FeedAddress", FeedAddress.ToString());
            sb.AppendFormat("{0}: {1}\n", "YouTubePlayList", YouTubePlayList.ToString());
            sb.AppendFormat("{0}: {1}\n", "EmailAddress", EmailAddress.ToString());
            sb.AppendFormat("{0}: {1}\n", "EmailSummary", EmailSummary.ToString());
            sb.AppendFormat("{0}: {1}\n", "SMTPServer", SMTPServer.ToString());
            sb.AppendFormat("{0}: {1}\n", "SMTPPort", SMTPPort.ToString());
            sb.AppendFormat("{0}: {1}\n", "UseDefaultCredentials", UseDefaultCredentials.ToString());
            if (!UseDefaultCredentials)
            {
                sb.AppendFormat("{0}: {1}\n", "SMTPUsername", "*********");
                sb.AppendFormat("{0}: {1}\n", "SMTPPassword", "*********");
            }
            sb.AppendFormat("{0}: {1}\n", "SMTPEnableSsl", SMTPEnableSsl.ToString());
            sb.AppendFormat("{0}: {1}\n", "EmailReturnAddress", EmailReturnAddress.ToString());
            sb.AppendFormat("{0}: {1}\n", "EmailReturnDisplayName", EmailReturnDisplayName.ToString());

            return(sb.ToString());
        }
Example #27
0
 public MailListener(SMTPServer aOwner, IPAddress localaddr, int port)
     : base(localaddr, port)
 {
     owner = aOwner;
 }
Example #28
0
 public EditModel()
 {
     SMTPServer = new SMTPServer();
 }
Example #29
0
 public Boolean ServerExists(SMTPServer server)
 {
     throw new NotImplementedException();
 }
Example #30
0
 public virtual void Initialize(SMTPServer server)
 {
     Server = server;
 }
Example #31
0
 public void Initialize(SMTPServer server)
 {
     throw new NotImplementedException();
 }
        public void Process()
        {
            if (processing || this.smtpServer == null)
            {
                return;
            }
            lock (lockObj)
            {
                processing = true;
            }

            QueueProcess queueProcess = new QueueProcess();

            int blockSleep = Convert.ToInt32(ConfigurationManager.AppSettings["BlockSleep"]);

            ClickOnceDMLib.Structs.Queue queue = queueProcess.GetQueue();

            if (queue != null)
            {
                InitSMTPServer();

                LogProcess.Info("In-Process Start");

                ILog log = new LogCounter(); // log interface

                foreach (Recipient recipient in queue.RecipientData)
                {
                    long baseTick = DateTime.Now.Ticks;

                    var smtp = from s1 in this.smtpServer
                               orderby s1.Weight ascending
                               select s1;

                    SMTPServer serverInfo = smtp.First();

                    SendMailProcess sendMailProcess = new SendMailProcess(log);

                    sendMailProcess.SetHostAndPort(serverInfo.Host, serverInfo.Port);

                    MailAddress mailAddress = null;

                    try
                    {
                        mailAddress = new MailAddress(recipient.Address.Trim(), recipient.Name);
                    }
                    catch (Exception ex)
                    {
                        LogProcess.Error(ex);
                        continue;
                    }

                    if (mailAddress != null)
                    {
                        sendMailProcess.Send(
                            new MailAddress(queue.TicketData.SenderAddress, queue.TicketData.SenderName),
                            new MailAddress[] { mailAddress },
                            queue.TicketData.Subject,
                            queue.TicketData.Body
                            );

                        serverInfo.SetWeight(TimeSpan.FromTicks(DateTime.Now.Ticks - baseTick).Milliseconds);
                    }
                }

                log.Flush(); // write log

                LogProcess.Info("In-Process End");

                Thread.Sleep(blockSleep);
            }

            processing = false;
        }
Example #33
0
 public MailSenderService(Sender sender, string message, string subject, ICollection <Recipient> recipients,
                          SMTPServer server)
     : this(sender, message, subject, server)
 {
     this.recipients = recipients;
 }
Example #34
0
 public MailSenderService(Sender sender, string message, string subject, SMTPServer server) : this(sender, server)
 {
     this.message = message;
     this.subject = subject;
 }