示例#1
0
 public SmtpEmailProvider(ISmtpConfig smtpConfig)
 {
     _smtpConfig = smtpConfig;
     _client     = () => new SmtpClient {
         Host = _smtpConfig.Host, Port = _smtpConfig.Port, Credentials = _smtpConfig.Credentials
     };
 }
示例#2
0
 public SmtpEmailProvider(string host, int port, ICredentialsByHost credentials)
 {
     _smtpConfig = new SmtpConfig(host, port, credentials);
     _client     = () => new SmtpClient {
         Host = _smtpConfig.Host, Port = _smtpConfig.Port, Credentials = _smtpConfig.Credentials
     };
 }
示例#3
0
 private async Task AuthenticateAsync(ISmtpConfig config)
 {
     try
     {
         await Smtp.AuthenticateAsync(config.Mail, config.SenderPassword);
     }
     catch (Exception ex)
     {
         throw new SmtpNotAuthenticatedException("Could not authenticate at smtp server", ex);
     }
 }
示例#4
0
 private async Task ConnectAsync(ISmtpConfig config)
 {
     try
     {
         await Smtp.ConnectAsync(config.Host, config.Port);
     }
     catch (Exception ex)
     {
         throw new SmtpNotConnectedException("Connection to smtp could not be made!", ex);
     }
 }
示例#5
0
        /// <summary>
        /// Constuct an instance of the <code>ISmtpClient</code> using the
        /// provided configuration.
        /// </summary>
        /// <exception cref="ArgumentNullException">If the provided configuration is <code>null</code></exception>
        /// <param name="config_">The configuration information required</param>
        public SmtpClient(ISmtpConfig config_)
        {
            if (null == config_)
            {
                throw new ArgumentNullException(nameof(config_));
            }

            Host        = config_.ServerName;
            Port        = config_.Port;
            Credentials = config_.UserCredentials;
            EnableSsl   = config_.EnableSsl;
            _config     = config_;
        }
示例#6
0
 public SmtpClientEmailSender(IMailConfig mailConfig, ISmtpConfig smtpConfig)
 {
     _mailConfig = mailConfig;
     _smtpConfig = smtpConfig;
 }
示例#7
0
 public async Task InitializeSmtpClientAsync(ISmtpConfig config)
 {
     await ConnectAsync(config);
     await AuthenticateAsync(config);
 }
示例#8
0
 public MailService(ISmtpConfig smtpConfig)
 {
     _smtpConfig = smtpConfig;
 }
示例#9
0
 public CustomerHasTakenLoanEventHandler(ISmtpConfig smtpConfig, IMailConfig mailConfig)
 {
     _smtpConfig = smtpConfig;
     _mailConfig = mailConfig;
 }
示例#10
0
 public LoanHasBeenPaidOffEventHandler(IMailConfig mailConfig, ISmtpConfig smtpConfig)
 {
     _mailConfig = mailConfig;
     _smtpConfig = smtpConfig;
 }
示例#11
0
 public EmailSender(ISmtpConfig config)
 {
     _config = config;
 }