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)
-
0
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:
- Switch to MailKit for Email Sending
- Install the
Volo.Abp.MailKit
NuGet package in your host projects. - In your module configuration, add:
- Install the
[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._
-
0
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
-
0
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.
-
0
hi
We don't want to bring the breaking changes.
Using
Mailkit
will help you find the problem.Thanks.