Open Closed

Overriding email template for two-factor code #931

DanielAndreasen created

Im attempting to override existing email templates based on the instructions described in the text templating document and the emailing document.

I was able to override the standard layout by following the instructions in this section (tried both options) but I don't feel like the documentation is very clear on how I should override specific templates such as the one used for sending two-factor codes.

Example of how I have changed the standard layout of emails

.tpl file

<!DOCTYPE html>
<html lang="en" xmlns="">
    <meta charset="utf-8" />
    <h1>This my header</h1>


      This is my footer...


    public class TwoFactorSendCodeDefinitionProvider : TemplateDefinitionProvider, ITransientDependency
        public override void Define(ITemplateDefinitionContext context)
            var emailLayoutTemplate = context.GetOrNull(StandardEmailTemplates.Layout);

            emailLayoutTemplate.WithVirtualFilePath("/Emailing/Templates/TwoFactorSendCoreTemplate.tpl", true);

Result (Password reset)


I was not able to find the source code of the email template used for sending two-factor codes in any ABP module. I want to know how I can I find this template and how I should override its .tpl file like in the example above.

Im aware of the "Text template management" that is provided with the account module but only a few templates can be edited:

I would also like to know how I should translate the text used in templates. Since I can't find the .tpl files, im unable to view the localization keys I should use to enable translation of emails. "Text template management" shows localization keys for some .tpl files like "PasswordResetLink" but adding these keys to my json localization files in my "Shared" project doesn't affect the emails that are sent.

  • ABP Framework version: v3.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no (not tiered)

3 Answer(s)
  • 1
    maliming created
    Support Team


    SendSecurityCode does not use a template, I will use a template to send email security code in the next version

  • 0
    DanielAndreasen created


    Thank you for the answer.

    So there is currently no way of customizing the email sent for email security code, even just the translation?

    Also, how about translation of the templates that exists? Should translation simply be done by adding the localization keys to the json file of my own culture, and then the module will pick that up? That doesn't seem to work for me.

  • 0
    maliming created
    Support Team


    So there is currently no way of customizing the email sent for email security code, even just the translation?

    I have implemented it and it will be available in 4.3.

    You can provide a new email template. Rewrite SendSecurityCodeModel to use this template to send emails.

    Please check this document: