FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Can't change the sender just before sending the email

Open Abdelrahmandev1984 opened this issue 3 years ago • 0 comments

As the sender has limited emails per day or per hour, I need to select the proper sender according to the number of receivers, I am using Mailkit sender and trying to do something like that but still send from the default sender configured in DI

fluentEmail.Sender = GetFluentEmailSender(fluentEmail.Sender, fluentEmail.Data.ToAddresses.Count);

The DI configuration:

services.AddFluentEmail(defaultFromEmail, defaultFromName).
                AddRazorRenderer(templateRootFolder);

services.AddSingleton<ISender>(new MailKitSender(
                new SmtpClientOptions
                {
                    Server = notificationSettings.EmailSettings.MailKitSender.Server,
                    Port = notificationSettings.EmailSettings.MailKitSender.Port,
                    Password = password,
                    UseSsl = notificationSettings.EmailSettings.MailKitSender.UseSsl,
                    User = notificationSettings.EmailSettings.MailKitSender.UserName,
                    SocketOptions = (MailKit.Security.SecureSocketOptions)notificationSettings.EmailSettings.MailKitSender.SocketOptions,
                    RequiresAuthentication = notificationSettings.EmailSettings.MailKitSender.RequiresAuthentication
                }

                ));

Is this a bug or am I misusing it?

Abdelrahmandev1984 avatar Apr 14 '22 11:04 Abdelrahmandev1984