Open Closed

How to send email? #1338


User avatar
0
yorytang created
  • ABP Framework version: v4.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:

I have configured mail setting , using IEmailSender object to send mail but dont receive any email and no error.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    hi

    Check your xxxDomainModule. It will use NullEmailSender in DEBUG mode.

    #if DEBUG
        context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
    #endif
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    hi

    Check your xxxDomainModule. It will use NullEmailSender in DEBUG mode.

    #if DEBUG 
        context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); 
    #endif 
    

    I have delete the code,but sending email error, is it caused by email setting error?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    HI

    Please use this demo to check your mail config.

    https://github.com/abpframework/abp-samples/tree/master/EmailSendDemo

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    I am a little confused about the mailing function. I think only 2 configurations are needed and no code is required. What else do I need to do?

    1. Config email setting
    2. Delete NullEmailSender code.
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please confirm your email config is correct.

    https://github.com/abpframework/abp-samples/blob/master/EmailSendDemo/src/EmailSendDemo/Program.cs#L11

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    Please confirm your email config is correct.

    https://github.com/abpframework/abp-samples/blob/master/EmailSendDemo/src/EmailSendDemo/Program.cs#L11

    Are these parameters not automatically read from the database,i have config it in setting page,why hardcode it?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    alper created
    Support Team Director

    it uses SettingProvider to get the configuration

    See the following links:

    1. https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs
    2. https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs
    3. https://docs.abp.io/en/abp/latest/Modules/Setting-Management
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    it uses SettingProvider to get the configuration

    See the following links:

    1. https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs
    2. https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs
    3. https://docs.abp.io/en/abp/latest/Modules/Setting-Management

    I know how to get configuration now, it needs to inject ISettingProvider first,but ApplicationModule.cs dont have the Constructor to inject it.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Those code are unnecessary. the email module will get the configuration automatically.

    https://docs.abp.io/en/abp/latest/Emailing

    This is test program, You can use it to confirm your email setting is correct.

    https://github.com/abpframework/abp-samples/blob/master/EmailSendDemo/src/EmailSendDemo/Program.cs#L11

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    hi

    Those code are unnecessary. the email module will get the configuration automatically.

    https://docs.abp.io/en/abp/latest/Emailing

    This is test program, You can use it to confirm your email setting is correct.

    https://github.com/abpframework/abp-samples/blob/master/EmailSendDemo/src/EmailSendDemo/Program.cs#L11

    Do you mean I dont need to config email param manually, just need to add mailkit package and using IMailKitSmtpEmailSender to send mail?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You need confirm your email setting is correct.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yorytang created

    thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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 v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.