Open Closed

Email Sending Error Due to Missing Tenant Configurations in SQL Server (Stored Only in Redis) #9357


User avatar
0
BryanSoria created
  • Exception message and full stack trace: Mail sending failed, please check your email configuration and try again 2025-05-22 13:25:59.806 -05:00 [ERR] Error sending test email: MailKit.Net.Smtp.SmtpProtocolException: The SMTP server has unexpectedly disconnected: Authentication failed: The provided authorization grant is invalid, expired, or revoked at MailKit.Net.Smtp.SmtpStream.ReadAheadAsync(CancellationToken cancellationToken) at MailKit.Net.Smtp.SmtpStream.ReadResponseAsync(CancellationToken cancellationToken) at MailKit.Net.Smtp.SmtpStream.SendCommandAsync(String command, CancellationToken cancellationToken) at MailKit.Net.Smtp.SmtpClient.SendCommandInternalAsync(String command, CancellationToken cancellationToken) at MailKit.Net.Smtp.SmtpClient.AuthenticateAsync(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken) at Volo.Abp.MailKit.MailKitSmtpEmailSender.ConfigureClient(SmtpClient client) at Volo.Abp.MailKit.MailKitSmtpEmailSender.BuildClientAsync() at Volo.Abp.MailKit.MailKitSmtpEmailSender.SendEmailAsync(MailMessage mail) at Volo.Abp.Emailing.EmailSenderBase.SendAsync(MailMessage mail, Boolean normalize) at Volo.Abp.Emailing.EmailSenderBase.SendAsync(String from, String to, String subject, String body, Boolean isBodyHtml, AdditionalEmailSendingArgs additionalEmailSendingArgs) at Volo.Abp.SettingManagement.EmailSettingsAppService.SendTestEmailAsync(SendTestEmailInput input) 2025-05-22 13:25:59.827 -05:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "Mail sending failed, please check your email configuration and try again.", "details": null, "data": {}, "validationErrors": null }

2025-05-22 13:25:59.828 -05:00 [WRN] Mail sending failed, please check your email configuration and try again. Volo.Abp.UserFriendlyException: Mail sending failed, please check your email configuration and try again. at Volo.Abp.SettingManagement.EmailSettingsAppService.SendTestEmailAsync(SendTestEmailInput input) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

  • Steps to reproduce the issue:
  1. From the Host user, create a new tenant.
  2. Log in as the newly created tenant.
  3. Navigate to the Emailing section to configure the email settings.
  4. Enter and save the configuration.
  5. Click on "Send Test Email" — the mentioned error message appears.
  • Additional comments:
  1. I verified that the email configurations are correctly stored in Redis.
  2. However, they are never saved in the tenant's SQL Server database.The system reads the data from Redis to display it in the "Emailing" interface, but when performing the email sending test, it seems to try to retrieve the configurations from SQL Server. Since they don't exist there, the process fails.
  3. This behavior occurs both in the context of the tenants and the host.
  • Project Configuration:
  1. ABP Studio Business Edition version 0.9.26
  2. Blazor Server
  3. Entity Framework Core
  4. SQL Server
  5. Multi-TenancyProject generated using the ABP Studio template
  • **Resources consulted without success:
  1. Email Sending
  2. MailKit Integration
  3. Sending Mail
  4. How to send email?
  5. Cannot send test email
  6. IEmailSender not working

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

    hi

    Can you share the content of the AbpSettings table?

    Thanks.

  • User Avatar
    1
    BryanSoria created

    Hello, Below are the screenshots showing the AbpSettings information:

    • Tenant AbpSettings:
    • Host AbpSettings:
      • Note: The hidden information in the image was configured at the tenant level, not at the host level. However, it appears in the host configuration, while in the tenant configuration it remains empty.
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think your email settings can be read correctly, but the value is wrong.

    You can check it by override the MailKitSmtpEmailSender

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IMailKitSmtpEmailSender), typeof(MailKitSmtpEmailSender), typeof(MyMailKitSmtpEmailSender))]
    public class MyMailKitSmtpEmailSender : MailKitSmtpEmailSender, IMailKitSmtpEmailSender, ITransientDependency
    {
        public MyMailKitSmtpEmailSender(
            ICurrentTenant currentTenant,
            ISmtpEmailSenderConfiguration smtpConfiguration,
            IBackgroundJobManager backgroundJobManager,
            IOptions<AbpMailKitOptions> abpMailKitConfiguration)
            : base(currentTenant, smtpConfiguration, backgroundJobManager, abpMailKitConfiguration)
        {
        }
    
        protected override Task ConfigureClient(SmtpClient client)
        {
            var host = SmtpConfiguration.GetHostAsync();
            var port = SmtpConfiguration.GetPortAsync();
            var userName = SmtpConfiguration.GetUserNameAsync();
            var password = SmtpConfiguration.GetPasswordAsync();
            var domain = SmtpConfiguration.GetDomainAsync();
            var enableSsl = SmtpConfiguration.GetEnableSslAsync();
            var useDefaultCredentials = SmtpConfiguration.GetUseDefaultCredentialsAsync();
    
            return base.ConfigureClient(client);
        }
    }
    
    

    https://support.sendgrid.com/hc/en-us/articles/17894803361819-Troubleshooting-535-Authentication-failed-Error

  • User Avatar
    0
    BryanSoria created

    Hi Thank you for your attention and time. I finally managed to solve the problem as it was a configuration issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great news

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 June 13, 2025, 11:37