public static EmailServicesBuilder AddFluentEmail(this IServiceCollection services, string defaultFromEmail, string defaultFromName = "") { if (services == null) { throw new ArgumentNullException(nameof(services)); } var builder = new EmailServicesBuilder(services); services.TryAdd(ServiceDescriptor.Transient <IEmail>(x => new Email(x.GetService <ITemplateRenderer>(), x.GetService <ISender>(), defaultFromEmail, defaultFromName) )); services.TryAddTransient <IEmailFactory, EmailFactory>(); return(builder); }
public static EmailServicesBuilder AddRazorRenderer(this EmailServicesBuilder builder) { builder.Services.TryAdd(ServiceDescriptor.Singleton <ITemplateRenderer, RazorRenderer>()); return(builder); }
public static EmailServicesBuilder AddSmtpSender(this EmailServicesBuilder builder, string host, int port) => AddSmtpSender(builder, new SmtpClient(host, port));
public static EmailServicesBuilder AddSmtpSender(this EmailServicesBuilder builder, Func <SmtpClient> clientFactory) { builder.Services.TryAdd(ServiceDescriptor.Scoped <ISender>(x => new SmtpSender(clientFactory))); return(builder); }
public static EmailServicesBuilder AddSmtpSender(this EmailServicesBuilder builder, SmtpClient smtpClient) { builder.Services.TryAdd(ServiceDescriptor.Scoped <ISender>(x => new SmtpSender(smtpClient))); return(builder); }