I'm working on shop where the customers will be imported by CSV, new customers will have NO password (password_hash = "").

The administrator will have to activate the new customers using the backend.

If a customer becomes activated, a random password should be generated and it should be included in the mail.

What I need to know is just where I find the code where the email will be sent. The code of the email template is "customer_create_account_email_template".

It's not the sendNewAccountEmail() method in app/code/core/Customer/Model/Customer.php and it's not either successProcessRegistration() in app/code/core/Customer/controllers/AccountController.php.

1 Answer 1


You didn't specify a Magento version so I'll explain it based on the current version CE If you are sure that sendNewAccountEmail() isn't used I'd suggest you have a look at sendPasswordReminderEmail() in app/code/core/Mage/Customer/Model/Customer.php.

Here is an explanation:

  • When you submit the customer submit form, the method Mage_Adminhtml_CustomerController::saveAction() is triggered.
  • The password and e-mail logic starts in the code block around line 305:

    $isNewCustomer = $customer->isObjectNew();
    try {
        $sendPassToEmail = false;
        // Force new customer confirmation
        if ($isNewCustomer) {
            if ($customer->getPassword() == 'auto') {
                $sendPassToEmail = true;
        Mage::dispatchEvent('adminhtml_customer_prepare_save', array(
            'customer'  => $customer,
            'request'   => $this->getRequest()
        // ...
    } // ...

    Here, the password for a new customer would be generated.

  • Next, the mails are sent:

    // Send welcome email
    if ($customer->getWebsiteId() && (isset($data['account']['sendemail']) || $sendPassToEmail)) {
        $storeId = $customer->getSendemailStoreId();
        if ($isNewCustomer) {
            $customer->sendNewAccountEmail('registered', '', $storeId);
        } elseif ((!$customer->getConfirmation())) {
            // Confirm not confirmed customer
            $customer->sendNewAccountEmail('confirmed', '', $storeId);
    if (!empty($data['account']['new_password'])) {
        $newPassword = $data['account']['new_password'];
        if ($newPassword == 'auto') {
            $newPassword = $customer->generatePassword();

    Normally, the mail template customer_create_account_email_template is used when a new user registered and confirmation is not required (i.e. $customer->sendNewAccountEmail('registered', '', $storeId); in the snippet above).

    As you imported the customer before and just re-save it with a auto-generated password, the second part of the code should apply and the mail should be sent here:


    This method sendPasswordReminderEmail() which can be found in app/code/core/Mage/Customer/Model/Customer.php uses the mail template configured as the "Remind E-Mail Template".

  • Thank you for answer. Well, I discovered that the code was in an extension for custom customer attributes, which overrides several methods, include the mail functions. And, I've been writing a csv importer which directly import into the database without using any magento classes, because I've been under time pressure to get an importer finished, which is runnable by a cron job. In the import, I just leave the password_hash empty, so it has to be generated first. I think it would have been better and easier to write the importer as a n98-magerun module.
    – Artisan72
    Commented Feb 9, 2015 at 4:25
  • Thanks for the explanation. It would be best then if you add this as an answer yourself and accept it (= click the check mark next to the answer). This is perfectly fine and every accepted answer helps to get our site out of Beta! Commented Feb 9, 2015 at 5:28

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.