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.


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
    
  • 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?

  • 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

  • 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.
  • 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

  • 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?

  • 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
  • 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.

  • 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

  • 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?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You need confirm your email setting is correct.

  • User Avatar
    0
    yorytang created

    thanks

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11