1 Answer(s)
-
0
You can create a new class inherits from
IEmailSenderpublic class MyCustomEmailSender : IEmailSender { public Task SendAsync(string to, string subject, string body, bool isBodyHtml = true) { throw new System.NotImplementedException(); } public Task SendAsync(string @from, string to, string subject, string body, bool isBodyHtml = true) { throw new System.NotImplementedException(); } public Task SendAsync(MailMessage mail, bool normalize = true) { throw new System.NotImplementedException(); } public Task QueueAsync(string to, string subject, string body, bool isBodyHtml = true) { throw new System.NotImplementedException(); } }alternatively, you can inherit from
EmailSenderBase, so you can just override theSendEmailAsync()public class MyCustomEmailSender : EmailSenderBase { public MyCustomEmailSender(IEmailSenderConfiguration configuration, IBackgroundJobManager backgroundJobManager) : base(configuration, backgroundJobManager) { } protected override Task SendEmailAsync(MailMessage mail) { //send your email } }And replace the existing implemantation with yours in your Application project's ApplicationModule. Remove the below code section
#if DEBUG context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); #endifand add
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, MyCustomEmailSender>());Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
