Open Closed

NullEmailSender service works all environments, not only debug #4036


User avatar
0
ElifKaya created

Hi,

I want to use NullEmailSender only debug configuration. But If I don't remove NullEmailSender service like below code on other environments, I can see only log file and I can not send email from pretest environment. Is this about ABP Framework? I think it doesn't need to remove NullEmailSender service when I used if DEBUG?

** context.Services.Remove(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); **

Thanks

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

ABP Framework version: v5.3.3

UI type: MVC

DB provider: EF Core

Tiered (MVC): yes

Exception message and stack trace:

Steps to reproduce the issue:"


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can use SmtpEmailSender like:

    context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, SmtpEmailSender>());

  • User Avatar
    0
    ElifKaya created

    hi

    You can use SmtpEmailSender like:

    context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, SmtpEmailSender>());

    But why we need to replace again, because I used NullEmailSender only if DEBUG tag.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I think you don't need to Remove in other environments.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on May 20, 2025, 06:55