Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Smtp settings not read for Tenant #8415


User avatar
0
ivanosw1 created

Hi, I have some problem with reading smtp settings (only for this). With a logged user in a Tenant : SettingManager.ChangeSettingForTenant(AbpSession.GetTenantId(), Abp.Net.Mail.EmailSettingNames.Smtp.Host, input.SmtpHost); writes correctly in database: Id CreationTime CreatorUserId LastModificationTime LastModifierUserId Name TenantId UserId Value 10154 2020-01-27 11:03:51.4605249 4 NULL NULL Abp.Net.Mail.Smtp.Host 2 NULL smtp.my.domain

But, when I read the same value with SmtpHost = SettingManager.GetSettingValueForTenant(Abp.Net.Mail.EmailSettingNames.Smtp.Host, AbpSession.GetTenantId()), and AbpSession.GetTenantId() return 2, I obtain 127.0.0.1 the is the default value.

Every other my setting works fine. There is something I'm missing?

ANZ 7.1.0 with Angular and Core 2

Thank you


10 Answer(s)
  • User Avatar
    0
    musa.demir created

    It works as expected. Can you please check if your input is right ?

  • User Avatar
    0
    ivanosw1 created

    Hi @demirmusa

    I'm sorry by I think that the expected behaviour is to obtain the Tenant value (smtp.my.domain) and not the Host value (127.0.0.1).

    The Tenant's value is correctly written on database.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ivanosw1

    Is your app multi tenant or single tenant ?

  • User Avatar
    0
    ivanosw1 created

    Multi tenant.

    I'm trying to debug the source code but I'm not able to set correctly VS based on this documentation https://aspnetboilerplate.com/Pages/Documents/Debugging. No pdbs are founded :'Abp.AspNetZeroCore.dll'. Cannot find or open the PDB file.' But this is another issue.

  • User Avatar
    0
    musa.demir created

    So the main problem is, your tenant db and host db is different. When you set Abp.Net.Mail.EmailSettingNames.Smtp.Host setting to smtp.my.domain for the tenant, it stores setting in tenant db. But then when you try to get the value it returns a value from host db, That's why it returns default value in that case?

    Am I wrong?

  • User Avatar
    0
    ivanosw1 created

    Yes, exactly.

  • User Avatar
    0
    musa.demir created

    Alright. Thanks ivanosw1. Let me check it.

  • User Avatar
    0
    ivanosw1 created

    Thank you. Just one clarification: -> Your tenant db and host db is different.

    No, host and tenant are on the same database.

  • User Avatar
    0
    musa.demir created

    Alright, I think it is because you dont allow tenant to change email. Set AbpZeroTemplateConsts.AllowTenantsToChangeEmailSettings to true.

    See: AppSettingProvider.cs#L52-L63

  • User Avatar
    0
    ivanosw1 created

    Thank you @demirmusa, the problem is solved.