示例#1
0
        public void ShouldReturnDummyGmailConfiguration()
        {
            ClientConfiguration configuration = ClientConfiguration.CreateSampleConfiguration();

            Assert.AreEqual("smtp.gmail.com", configuration.Host);
            Assert.AreEqual(587, configuration.Port.Value);
            Assert.AreEqual("username", configuration.UserName);
            Assert.AreEqual("password", configuration.Password);
            Assert.AreEqual(true, configuration.Ssl);
        }
示例#2
0
        static void Main(string[] args)
        {
            ClientConfiguration configuration;
            Options             options = Options.Create(args, new CommandLineParserSettings(Console.Out));
            Mail smtpMail;

            if (!String.IsNullOrEmpty(options.SampleConfigurationFilePath))
            {
                configuration = ClientConfiguration.CreateSampleConfiguration();
                configuration.Save(options.SampleConfigurationFilePath);
                Console.WriteLine("Sample configuration file generated at {0}", Path.GetFullPath(options.SampleConfigurationFilePath));
                return;
            }

            ErrorList optionErrors = options.Validate();

            if (optionErrors.HasErrors)
            {
                PrintErrors(optionErrors);
                return;
            }

            configuration = ClientConfiguration.Create(options.ConfigurationFile);
            ErrorList configurationErrors = options.Validate();

            if (configurationErrors.HasErrors)
            {
                PrintErrors(configurationErrors);
                return;
            }

            try {
                smtpMail = new Mail(options, new NativeSmtpClient(configuration));
                smtpMail.Send();
            }
            catch (Exception ex) {
                Console.WriteLine("Unable to send the email reason: {0}", ex.Message);
            }
        }