Open Closed

Email sending stops working after a while #9670


User avatar
0
LW created

Hi,

We have an ABP Framework applications running on Azure App Services. E-mail is sent via SendGrid SMTP.

Issue After the app has been running for a while, outgoing e-mails stop being sent. Nothing appears in our SendGrid activity log, so the messages never reach SendGrid. Restarting our two web apps (API host and Auth server) immediately restores e-mail delivery, but the problem reappears after some days of uptime.

Could you suggest what might cause this and what to check next?


4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • This issue is commonly related to the underlying SMTP client implementation or resource exhaustion in long-running applications. By default, ABP uses the .NET SmtpClient, which is known to have connection pooling and resource management issues, especially in cloud environments like Azure App Services. Over time, connections may not be released properly, leading to failures in sending emails until the application is restarted.

    • The ABP documentation strongly recommends using MailKit instead of the default SmtpClient for production scenarios. MailKit is more robust, supports modern protocols, and is less prone to these issues.

    What to check and do next:

    1. Switch to MailKit for Email Sending
      • Install the Volo.Abp.MailKit NuGet package in your host projects.
      • In your module configuration, add:

    [DependsOn(typeof(AbpMailKitModule))] public class YourModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { Configure

       - Remove or comment out any code that registers `NullEmailSender` or uses the default `SmtpClient`.
    
    2. **Check for Resource Exhaustion**
       - Monitor your application logs for exceptions related to sockets, timeouts, or resource limits.
       - Ensure your App Service plan has sufficient resources and is not hitting connection or memory limits.
    
    3. **Review Background Job Handling**
       - If you use background jobs for email sending, ensure jobs are not piling up due to failures, which can cause further issues.
    
    4. **Test Email Configuration**
       - Use the ABP Setting Management UI or configuration files to verify your SMTP settings are correct and up to date.
    
    5. **Restart as a Temporary Workaround**
       - While restarting restores functionality, it is not a long-term solution. Migrating to MailKit is the recommended fix.
    
    **References:**
    - [ABP Emailing Documentation](https://docs.abp.io/en/abp/latest/Emailing)
    - [ABP MailKit Integration](https://docs.abp.io/en/abp/latest/MailKit)
    - [Configuring for Production](https://abp.io/docs/latest/deployment/configuring-production)
    
    ---
    _This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon._
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can override the default SMTP email sending service and log some information.

    The issue might not be with your application, so check the Mail send output in the logs to troubleshoot the problem.

    Additionally, you can try using MailKit or the SendGrid HTTP API to send the emails.

    We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit(https://abp.io/docs/latest/framework/infrastructure/mail-kit) or other libraries instead. For more information, see https://github.com/dotnet/platform-compat/blob/master/docs/DE0005.md

    Thanks

  • User Avatar
    0
    LW created

    Hello, We will try Mailkit. I think Abp should move away from using the default smtp email sending service since the smtp client is clearly not meant to be used this way.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We don't want to bring the breaking changes.

    Using Mailkit will help you find the problem.

    Thanks.

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 12, 2025, 10:20