Activities of "cbogner85"

Yes, now it works! Thank you very much for your blazing-fast replies!

Hi maliming,

thank you!

Unfortunately, this doesn't work... if I create my own class MyBackgroundEmailSendingJobArgs, jobs fail because of the different name:

Undefined background job for the job name: MyProject.Extensions.MyBackgroundEmailSendingJobArgs

Also tried to create a BackgroundEmailSendingJobArgs in the same namespace (Volo.Abp.Emailing) , then jobs are recognized from the worker, but tenant is null again and it uses hosts email settings, although I set in my QueueAsync :(

   public async override Task QueueAsync(string to, string subject, string body, bool isBodyHtml = true, AdditionalEmailSendingArgs additionalEmailSendingArgs = null)
   {

       if (!BackgroundJobManager.IsAvailable())
       {
           await SendAsync(to, subject, body, isBodyHtml, additionalEmailSendingArgs);
           return;
       }

       await BackgroundJobManager.EnqueueAsync(
           new BackgroundEmailSendingJobArgs   
           {
               TenantId = CurrentTenant.Id,
               To = to,
               Subject = subject,
               Body = body,
               IsBodyHtml = isBodyHtml,
               AdditionalEmailSendingArgs = additionalEmailSendingArgs
           }
       );
   }

Anything I can do or do I have to wait for the next minor release? It's some kind of critical as people can't activate their accounts if email confirmation is required and we receive many support tickets from people who can't reset their passwords.

Thanks, that worked!

Now the following error is logged:

Setting value for 'Abp.Mailing.Smtp.UserName' is null or empty!

Of course, it is not empty for any tenant. Therefore I also logged the current tenant id and found out that it's empty, too... so email settings are retrieved from the host instead of the current tenant. Since I need different email settings for tenants, I can't just define email settings on the host to make it working again.

I further investigated ABP's source code. Mails are queued in AccountEmailer.cs, I extended it as well and logged the current tenant inside SendPasswortResetLinkAsync. Tenant id is correctly logged, and also in SmtpEmailSender's QueueAsync. But in SendAsync it is lost. It seems that the problem is in BackgroundJobManager. Maybe this is a bug?

Hi maliming,

thanks for the hint. I'd like to try that, but I don't manage to override SmtpEmailSender. I tried the following:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(ISmtpEmailSender), typeof(SmtpEmailSender), typeof(EmailSenderBase), typeof(CustomSmtpEmailSender))]

    public class CustomSmtpEmailSender : SmtpEmailSender
    {
        protected IAuditingManager AuditingManager { get; set; }
        public CustomSmtpEmailSender(ISmtpEmailSenderConfiguration smtpConfiguration, IBackgroundJobManager backgroundJobManager, IAuditingManager auditingManager) : base(smtpConfiguration, backgroundJobManager)
        {
            AuditingManager = auditingManager;
        }

        private async Task LogData()
        {
            using (var auditingScope = AuditingManager.BeginScope())
            {
                string username = await SmtpConfiguration.GetUserNameAsync();
                string password = await SmtpConfiguration.GetPasswordAsync();
                if (string.IsNullOrEmpty(password))
                {
                    password = "empty";
                }
                else
                {
                    password = "hidden";
                }
                string host = await SmtpConfiguration.GetHostAsync();
                int port = await SmtpConfiguration.GetPortAsync();

                AuditingManager.Current.Log.Comments.Add(string.Format("Emailsettings: SMTP: {0}, Port:{1}, Username: {2}, Password: {3}", host, port, username, password));
                await auditingScope.SaveAsync();
            }
        }

        protected async override Task SendEmailAsync(MailMessage mail)
        {

            await LogData();
            await base.SendEmailAsync(mail);
        }

        public async override Task SendAsync(MailMessage mail, bool normalize = true)
        {
            await LogData();
            await base.SendAsync(mail, normalize);
        }

        public async override Task SendAsync(string from, string to, string subject, string body, bool isBodyHtml = true, AdditionalEmailSendingArgs additionalEmailSendingArgs = null)
        {
            await LogData();
            await base.SendAsync(from, to, subject, body, isBodyHtml, additionalEmailSendingArgs);
        }

        public async override Task SendAsync(string to, string subject, string body, bool isBodyHtml = true, AdditionalEmailSendingArgs additionalEmailSendingArgs = null)
        {
            await LogData();
            await base.SendAsync(to, subject, body, isBodyHtml, additionalEmailSendingArgs);
        }
    }

But no data is logged, I also tried to set breakpoints and found out that none of the overriden methods are reached when sending mails. What am I doing wrong? I have overriden other ABP services in the past using the same way and it worked.

(Also tried to replace the service in WebModule using context.Services.Replace(ServiceDescriptor.Transient<SmtpEmailSender, CustomSmtpEmailSender>()); but didn't work either).

Thanks for you support!

Hi maliming,

thanks for you quick response. I already did that, no Strato SMTP settings were stored there:

Restarted the server again last night, now it seems the cache (?) was refreshed, however, it still doesn't work. Now I get the following error:

[ERR] Failure sending mail.
System.Net.Mail.SmtpException: Failure sending mail.
 ---> System.Net.Sockets.SocketException (10061): A connection could not be established because the target computer refused to connect.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.TaskToAsyncResult.End(IAsyncResult asyncResult)
   at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
   at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.InitializeConnectionCallback(IAsyncResult result)
--- End of stack trace from previous location ---
   at System.Net.Mail.SmtpClient.ConnectCallback(IAsyncResult result)
   --- End of inner exception stack trace ---
   at Volo.Abp.Emailing.Smtp.SmtpEmailSender.SendEmailAsync(MailMessage mail)
   at Volo.Abp.Emailing.EmailSenderBase.SendAsync(MailMessage mail, Boolean normalize)
   at Volo.Abp.Emailing.EmailSenderBase.SendAsync(String to, String subject, String body, Boolean isBodyHtml, AdditionalEmailSendingArgs additionalEmailSendingArgs)
   at Volo.Abp.Emailing.BackgroundEmailSendingJob.ExecuteAsync(BackgroundEmailSendingJobArgs args)
   at Volo.Abp.BackgroundJobs.BackgroundJobExecuter.ExecuteAsync(JobExecutionContext context)

However, sending a test mail from email setting dialog works (as all other emails sent from my own code work, too).

Did you see contents of AbpBackgroundJobs I posted above? Is it normal that "from" is null?

Hi liangshiwei,

thanks for your reply. I can't believe I overlooked that (as I mentioned before, it must have been something completely obvious).

As far as I unterstood, certificate validation shouldn't be disabled as it makes the app vulnerable to man in the middle attacks. However, this helps as I can see the detailed error now (SslPolicyErrors.RemoteCertificateChainErrors) and hopefully I'll find out how to make Android accept our certificates before going live. And in the meantime, I can test my app on production with the certifcate validation disabled.

Thanks!

To add some details what I've already tried: I found out that Android doesn't accept all certificate authorities. Therefore, I added the intermediate certificate to Platforms/Android/Resources/raw and modified network_security_config.xml as described here and here. (Actually my application isn't certified from Let's Encrypt but rather ZeroSSL, as I had to switch for some reason, but certificates are generated using Certify the Web). I also tried to add my certificate and the whole chain, nothing worked out...

This is what network_security_config.xml looks like:

(of course, productionsite.com is actually replaced with the URL of my production environment)

This is the folder structure:

Also, network_security_config.xml seems to be correctly attached to AndroidManifest.xml

I also tried to manually install the root and intermediate authorities to the emulator, didn't work either.

I have no idea what I'm doing wrong...

PS: Out of curiosity, I tried to set RemoteServices > Default > BaseUrl to microsoft.com (and added microsoft.com to allowed domains in network_security_config.xml). Even then the certificate rejection occurs. Therefore I suspect it's not really a problem with the authority, but something inside MAUI that rejects just every outgoing connection/ certificate.

Answer

Hi @ensin,

thanks for your reply!

Both approaches work almost as expected, except for the fact that, because of disabling JS style loading, switching themes doesn't work properly - nothing happens after clicking on a theme name.

I worked around this by adding onclick="location.reload()" to the menu items:

Is there a better solution?

Thanks in advance and best regards

Answer

Hello,

I'm already using LeptonX and have imeplemented custom themes. What I'm trying to accomplish: enable different themes based on the current tenant (only visible to this specific tenant) and set a different DefaultStyle based on the current tenant. The documentation shows how to hide styles, but in WebModule we don't have access to the current tenant as it runs at application startup and not at every page request.

Best regards

Same here. Hopefully this gets fixed soon.

Showing 1 to 10 of 27 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11