I know customer's password has been removed from Magento 2 for security reasons but it is requirement.

Default Magento 2 not provide a password with new account email. but we have required password in the welcome email.

Default Magento 2 Mail Template:

<!--@vars { 
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>
<p>{{trans "Welcome to %store_name." store_name=$store.getFrontendName()}}</p>
        'To sign in to our site, use these credentials during checkout or on the <a href="%customer_url">My Account</a> page:'

<table class="email-credentials">
        <th>{{trans "Email:"}}</th>
        <td>{{var customer.email}}</td>
        <th>{{trans "Password:"}}</th>
        <td><em>{{trans "Password you set when creating account"}}</em></td>

I want: {{var customer.password}}

But the issue is that password is not setting in the mail.

Can you please let me know how I can set customer password in the mail template or any other solution.


3 Answers 3


Email template variable {{var customer.password}} has been removed from Magento 2 for some security reasons. If you want to send the password to a customer on new account creation, then you have to use your custom email template. Follow below steps.

  1. Put a custom controller's action in your signup form.
  2. Get the email and password in your custom controller using post method.
  3. Create a custom email template and store your password in custom variable.
  4. Now you can send customer's password using a custom variable.
  • 2
    Perhaps it would be a nicer solution to use a plugin / interceptor instead of a custom controller. You could wrap around \Magento\Customer\Controller\Account\CreatePost::execute() to fetch the password and \Magento\Customer\Model\AccountManagement::createAccountWithPasswordHash() to add the password as a custom attribute or an extension attribute to the customer data model. But you would still need to overrule the email template to include the password. I'm not sure how to retrieve a custom attribute or extension attribute in there, but perhaps this helps you a bit. Commented May 22, 2017 at 7:24

As Dinesh mentioned, the customer's password has been removed from Magento 2 for security reasons. Adding it back in will make your store less secure.

If you are unsure of visitors being able to remember their passwords, make sure the Forgot Password functionality is highlighted and easy to use for your users.

  • Yes, I know Magento 2 removed it for security reason but its requirement. Commented May 24, 2017 at 9:48

Just create New Account Email Template from Marketing -> Email Template and

       <th>{{trans "Password:"}}</th>
       <td><em>{{trans "Password you set when creating account"}}</em>     </td>

You have to use below way instead of above code in email template,

   <th>{{trans "Password:"}}</th>
   <td><em>{{var customer.password}}</em></td>

Now set your New Account email template from Stores -> Customer Configuration

Clear Cache.

  • There is no password variable in the email template. So how can I add ? {{var customer.password}} Commented May 25, 2017 at 4:57
  • You have to just set {{var customer.password}} to get plain customer password in email. Commented May 25, 2017 at 4:58
  • By default New Account email template have customer object and customer object contains password field. so you can use directly as above. Commented May 25, 2017 at 5:00
  • There is encrypt password in customer object I need plain password Commented May 25, 2017 at 5:05
  • Nope, the customer password is blank Commented Nov 1, 2018 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.