Beispiel #1
0
        public void Set(MailConnectionParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.Host, parameters.Host);
            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.MailBox, parameters.Mailbox);
            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.Password, parameters.Password);
            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.SslEnabled, parameters.IsSslEnabled.ToString());
            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.Port, parameters.Port.ToString());
            _configurationProvider.SetValue(ConfigurationKeys.MailOutbox.User, parameters.Username);
        }
Beispiel #2
0
        public MailConnectionParameters Get()
        {
            var mailConnectionParameters = new MailConnectionParameters
            {
                Host         = GetConfig(ConfigurationKeys.MailOutbox.Host),
                Mailbox      = GetConfig(ConfigurationKeys.MailOutbox.MailBox),
                Password     = GetConfig(ConfigurationKeys.MailOutbox.Password),
                IsSslEnabled = Convert.ToBoolean(GetConfig(ConfigurationKeys.MailOutbox.SslEnabled)),
                Port         = Convert.ToInt32(GetConfig(ConfigurationKeys.MailOutbox.Port)),
                Username     = GetConfig(ConfigurationKeys.MailOutbox.User)
            };

            return(mailConnectionParameters);
        }
Beispiel #3
0
        public MailConnectionParameters TryGet()
        {
            var mailConnectionParameters = new MailConnectionParameters
            {
                Host         = TryGetConfig(ConfigurationKeys.MailOutbox.Host, "contoso.com"),
                Mailbox      = TryGetConfig(ConfigurationKeys.MailOutbox.MailBox, "*****@*****.**"),
                Password     = TryGetConfig(ConfigurationKeys.MailOutbox.Password, "p@$$w0rd"),
                IsSslEnabled = Convert.ToBoolean(TryGetConfig(ConfigurationKeys.MailOutbox.SslEnabled, "false")),
                Port         = Convert.ToInt32(TryGetConfig(ConfigurationKeys.MailOutbox.Port, "25")),
                Username     = TryGetConfig(ConfigurationKeys.MailOutbox.User, "mail")
            };

            return(mailConnectionParameters);
        }
        public IMailSender BeginSend([NotNull] MailConnectionParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var client = new SmtpClient(parameters.Host, parameters.Port)
            {
                Credentials = new NetworkCredential(parameters.Username, parameters.Password),
                EnableSsl   = parameters.IsSslEnabled
            };

            return(new SmtpMailSender(client, parameters.Mailbox));
        }