/// <summary>
        /// Adds Mailgun Email sender to services.
        /// </summary>
        public static IServiceCollection AddMailgunEmailSender(
            this IServiceCollection service,
            MailgunEmailOptions options,
            bool useAsDefaultSender = true)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            // check options
            options.AssertValid();

            service.TryAddSingleton(options);
            service.TryAddSingleton <IMailgunEmailSender, MailgunEmailSender>();
            if (useAsDefaultSender)
            {
                service.TryAddSingleton <IEMailSender>(c => c.GetRequiredService <IMailgunEmailSender>());
            }

            return(service);
        }
        public MailgunEmailSender(
            ILogger <MailgunEmailSender> logger,
            MailgunEmailOptions mailgunEmailOptions)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _mailgunEmailOptions = mailgunEmailOptions ?? throw new ArgumentNullException(nameof(mailgunEmailOptions));
            _mailgunEmailOptions.AssertValid();
        }