public EmailSenderService( IOptions <EmailSenderOptions> optionsAccessor, IMailTemplatesCache mailTemplatesCache) { options = optionsAccessor.Value; this.mailTemplatesCache = mailTemplatesCache; }
public EmailSender(IOptionsSnapshot <EmailSenderOptions> options, ILogger <EmailSender> logger) { _logger = logger; if (options.Value == null) { _logger.LogError($"EmailSender options are null"); throw new ArgumentNullException($"EmailSender options are null"); } EmailSenderOptions emailSender = options.Value; _smtpClient = new SmtpClient(emailSender.Ip, emailSender.Port) { DeliveryFormat = SmtpDeliveryFormat.International, Credentials = new NetworkCredential(emailSender.UserName, emailSender.Password), EnableSsl = emailSender.UseSSL, }; _senderEmail = emailSender.SenderEmail; if (string.IsNullOrEmpty(_senderEmail)) { _senderEmail = emailSender.SenderName; } _senderDisplayName = emailSender.SenderDisplayName; }
public EmailSender(IOptionsSnapshot <EmailSenderOptions> options, IWebHostEnvironment hostingEnvironment, ILogger <EmailSender> logger) #endif { _logger = logger; if (options.Value == null) { _logger.LogError($"EmailSender options are null"); throw new ArgumentNullException($"EmailSender options are null"); } EmailSenderOptions emailSender = options.Value; bool enambleSsl = true; if (hostingEnvironment.IsDevelopment()) { enambleSsl = false; } _smtpClient = new SmtpClient(emailSender.Ip, emailSender.Port) { DeliveryFormat = SmtpDeliveryFormat.International, EnableSsl = enambleSsl, UseDefaultCredentials = false, Credentials = new NetworkCredential(emailSender.UserName, emailSender.Password) }; _senderName = emailSender.SenderName; }
public Task SendAsync(IdentityMessage message) { sysReferences = new SysReferencesService(new UnitOfWork(new AppContext())); sender = new EmailSender(); var sendOptions = new EmailSenderOptions(); int port = 0; if (int.TryParse(sysReferences.GetValueByKey(SysConstants.EmailGate_SmtpPort), out port)) { sendOptions.Port = port; } else { throw new InvalidCastException("Error parse email port!"); } sendOptions.Body = message.Body; sendOptions.Subject = message.Subject; sendOptions.From = sysReferences.GetValueByKey(SysConstants.EmailGate_Login); sendOptions.To = message.Destination; sendOptions.Host = sysReferences.GetValueByKey(SysConstants.EmailGate_SmtpServer); sendOptions.EnableSSL = true; sendOptions.IsBodyHtml = true; sendOptions.Attachment = false; sendOptions.UseDefaultCredentials = true; sendOptions.Password = sysReferences.GetValueByKey(SysConstants.EmailGate_Password); sender.Send(sendOptions); return(Task.FromResult(0)); }
public MessageHandler(IMessageSender messageSender, ILogger <MessageSender> logger, IOptions <EmailSenderOptions> emailSenderOptions) { _messageSender = messageSender; _logger = logger; _emailSenderOptions = emailSenderOptions.Value; _emailSender = RestService.For <IEmailSenderApi>(_emailSenderOptions.BaseUrl); }
public EmailSender(ILogger <EmailSender> logger, IOptions <EmailSenderOptions> options, ISendRequestValidator validator, IEmailService emailService) { this.logger = logger; this.validator = validator; this.emailService = emailService; this.options = options.Value; }
public EmailSender(EmailSenderOptions emailSenderOptions) { this.options = emailSenderOptions ?? throw new ArgumentNullException("configuration"); client = new SmtpClient(this.options.Host, this.options.Port); client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(this.options.Email, this.options.Password); }
private void SendEmail(string toEmail, string subject, string message, EmailSenderOptions Options) { MailMessage mail = GetMailMessage(toEmail, subject, message, Options.emailSender, Options.emailUserName, Options.useHtml); SmtpClient client = GetSmtpClient(Options.emailServer, Options.emailPort, Options.requiresAuthentication, Options.emailEmail, Options.emailPassword, Options.useSsl); client.Send(mail); }
public EmailSender(ILogger <EmailSender> logger, IOptions <EmailSenderOptions> optionsAccessor) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _options = optionsAccessor.Value ?? throw new ArgumentNullException(nameof(optionsAccessor)); if (_options.SendGridKey == null || _options.SendGridUser == null) { throw new ArgumentNullException($"{nameof(EmailSender)}: SendGridKey or SendGridUser not set on launch. Please configure."); } }
public EmailController() { Options = new EmailSenderOptions() { Host = "smtp.gmail.com", Port = 587, Password = "******", Email = "*****@*****.**", Name = "Luis de la cruz", EnableSsl = true, }; }
public EditAphorismModel( UserManager <ApplicationUser> userManager, IAphorismsService aphorismsService, IConfiguration configuration, IEmailSender emailSender, IOptions <EmailSenderOptions> emailSenderOptions) { _userManager = userManager; _aphorismsService = aphorismsService; _configuration = configuration; _emailSender = emailSender; _emailSenderOptions = emailSenderOptions.Value; }
public EmailSenderRepository(IOptions <EmailSenderOptions> options) { Options = options.Value; Cliente = new SmtpClient() { Host = Options.Host, Port = Options.Port, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(Options.Email, Options.Password), EnableSsl = Options.EnableSsl, }; }
public AccountController( UserManager <Customer> userManager, SignInManager <Customer> signInManager, IOptions <IdentityCookieOptions> identityCookieOptions, IEmailSender emailSender, IOptions <EmailSenderOptions> options, IMapper mapper) { _userManager = userManager; _signInManager = signInManager; _externalCookieScheme = identityCookieOptions.Value.ExternalCookieAuthenticationScheme; _emailSender = emailSender; _options = options.Value; _mapper = mapper; }
//[Test] public void IntegrationTest() { var options = new EmailSenderOptions { Server = "mail005.nameserver.sk", Port = 587, User = "******", Password = "******", Sender = "*****@*****.**" }; var sender = new SecureSmtpSender(_logger, options); sender.Send("test", "<h3>From unit test</h3>", "*****@*****.**"); }
public RegisterModel( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, ILogger <RegisterModel> logger, IEmailSender emailSender, IConfiguration configuration, IOptions <EmailSenderOptions> options) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; _configuration = configuration; _emailSenderOptions = options.Value; }
public Task Execute(EmailSenderOptions options, string subject, string body, string email, bool isBodyHtml) { MailMessage msg = new MailMessage(options.SenderEmailAddress, email); msg.Subject = subject; msg.Body = body; msg.IsBodyHtml = isBodyHtml; using (SmtpClient client = new SmtpClient())// "smtp.gmail.com", 465) { client.Host = options.Host; client.Port = options.Port; client.EnableSsl = options.EnableSsl; client.Credentials = new System.Net.NetworkCredential(options.UserName, options.Password); return(client.SendMailAsync(msg)); } }
public void ConfigureServices(IServiceCollection services) { var emailSenderOptions = new EmailSenderOptions(); this.Configuration.GetSection("EmailSender").Bind(emailSenderOptions); services.AddInfrastructure(new MongoConnectionString(this.Configuration.GetConnectionString("MongoDb")), emailSenderOptions); services.AddMediatR(typeof(Startup), typeof(ICommand)); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Codibly.Services.Mailer", Version = "v1", }); }); }
public EmailSender(IOptionsSnapshot <EmailSenderOptions> options, ILogger <EmailSender> logger) { _logger = logger; if (options.Value == null) { _logger.LogError($"EmailSender options are null"); throw new Exception($"EmailSender options are null"); } EmailSenderOptions emailSender = options.Value; _smtpClient = new SmtpClient(emailSender.Ip, emailSender.Port) { DeliveryFormat = SmtpDeliveryFormat.International, EnableSsl = true, UseDefaultCredentials = false, Credentials = new NetworkCredential(emailSender.UserName, emailSender.Password) }; _senderName = emailSender.SenderName; }
public void Send(EmailSenderOptions options) { if (options == null) { throw new NullReferenceException("options"); } client = new SmtpClient(options.Host, options.Port); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = options.UseDefaultCredentials; client.Credentials = new NetworkCredential(options.From, options.Password); client.EnableSsl = options.EnableSSL; MailMessage mail = new MailMessage(options.From, options.To); mail.Subject = options.Subject; mail.Body = options.Body; mail.IsBodyHtml = options.IsBodyHtml; if (options.Attachment) { var attach = new Attachment(options.AttachmentPath); attach.ContentDisposition.Inline = true; attach.ContentDisposition.DispositionType = DispositionTypeNames.Inline; attach.ContentId = options.CotnentId; attach.ContentType.MediaType = options.MediaType; attach.ContentType.Name = Path.GetFileName(options.AttachmentPath); mail.Attachments.Add(attach); } client.Send(mail); }
private readonly EmailSenderOptions options; // SendGrid public EmailSender(IOptions <EmailSenderOptions> optionsAccessor) { this.options = optionsAccessor.Value; }
public EmailSenderService(IOptions <EmailSenderOptions> optionsAccessor) { options = optionsAccessor.Value; }
public EmailSender(EmailSenderOptions options) { this.options = options; }
public EmailSender(IOptions <EmailSenderOptions> options, HttpContextService httpContextService, UserManager <User> userManager) { _options = options.Value; _httpContextService = httpContextService; _userManager = userManager; }
public EmailSender(SendGridClient emailClient, EmailSenderOptions senderOptions) { _emailClient = emailClient; _senderOptions = senderOptions; }
public EmailSender(IOptions <EmailSenderOptions> emailOptions) { _emailSenderOptions = emailOptions.Value; }
public EmailSender(EmailSenderOptions option) { Config(option); }
public EmailNotificator(IOptions <EmailSenderOptions> emailSenderOptions) { _emailSenderOptions = emailSenderOptions.Value; _fromAddress = new MailboxAddress(_emailSenderOptions.From); _networkCredential = new NetworkCredential(_emailSenderOptions.From, _emailSenderOptions.Password); }
public void Config(EmailSenderOptions options) { Options = options ?? throw new ArgumentNullException(nameof(options)); }
public EmailSender(IOptions <EmailSenderOptions> settings, ILogger <EmailSender> logger) { _logger = logger; _options = settings.Value; }
public EmailSender(IServiceProvider serviceProvider, IOptionsSnapshot <EmailSenderOptions> senderOptions) { _serviceProvider = serviceProvider; _senderOptions = senderOptions.Value; }