public static BabouEmailServicesBuilder AddBabouEmail(this IServiceCollection services, string defaultFromEmail, string defaultFromName = "")
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            var builder = new BabouEmailServicesBuilder(services);

            services.TryAdd(ServiceDescriptor.Transient <IBabouEmail>(x =>
                                                                      new BabouEmail(x.GetService <IBabouSender>(), defaultFromEmail, defaultFromName)
                                                                      ));

            services.TryAddTransient <IBabouEmailFactory, BabouEmailFactory>();

            return(builder);
        }
Esempio n. 2
0
 public static BabouEmailServicesBuilder AddSmtpSender(this BabouEmailServicesBuilder builder, Func <SmtpClient> clientFactory)
 {
     builder.Services.TryAdd(ServiceDescriptor.Scoped <IBabouSender>(x => new SmtpSender(clientFactory)));
     return(builder);
 }
Esempio n. 3
0
 public static BabouEmailServicesBuilder AddSmtpSender(this BabouEmailServicesBuilder builder, string host, int port, string username, string password) => AddSmtpSender(builder,
                                                                                                                                                                         new SmtpClient(host, port)
 {
     EnableSsl = true, Credentials = new NetworkCredential(username, password)
 });
Esempio n. 4
0
 public static BabouEmailServicesBuilder AddSmtpSender(this BabouEmailServicesBuilder builder, string host, int port) => AddSmtpSender(builder, new SmtpClient(host, port));
Esempio n. 5
0
 public static BabouEmailServicesBuilder AddSmtpSender(this BabouEmailServicesBuilder builder, SmtpClient smtpClient)
 {
     builder.Services.TryAdd(ServiceDescriptor.Scoped <IBabouSender>(x => new SmtpSender(smtpClient)));
     return(builder);
 }
 public static BabouEmailServicesBuilder AddMailGunSender(this BabouEmailServicesBuilder builder, string domainName, string apiKey, MailGunRegion mailGunRegion = MailGunRegion.USA)
 {
     builder.Services.TryAdd(ServiceDescriptor.Scoped <IBabouSender>(x => new MailGunSender(domainName, apiKey, mailGunRegion)));
     return(builder);
 }