/// <summary> /// Constructor /// </summary> /// <param name="eMailOptions">Settings of the SMTP server</param> public EMailSender(IOptions <EMailOptions> eMailOptions) { _eMailOptions = eMailOptions.Value; if (!string.IsNullOrWhiteSpace(eMailOptions.Value.Host) && !string.IsNullOrWhiteSpace(_eMailOptions.UserName) && !string.IsNullOrWhiteSpace(_eMailOptions.Password)) { _client = new SmtpClient(_eMailOptions.Host, _eMailOptions.Port) { Credentials = new NetworkCredential(_eMailOptions.UserName, _eMailOptions.Password), EnableSsl = _eMailOptions.EnableSsl }; } }
public EMailService(IConfiguration configuration) { _configuration = configuration; _eMailOptions = _configuration.GetSection("EMailConfiguration").Get <EMailOptions>(); }