Where I should write a code for send an email after adding new account/forgot password/reset password in magento ?


closed as unclear what you're asking by Fabian Schmengler, Marius Feb 13 '15 at 21:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


You do not have to write code for send emails. Magento itself contains this facility. So you just need to setup the required configurations from the admin panel.

First set-up the email settings.

  1. Log in to your admin panel and go to System > Configuration
  2. Select System under Advanced
  3. There will be a tab as Mail Sending Settings. So you can set up email settings and save configurations.

Secondly enable sending emails on create account / reset password / forgot password

  1. Go to System > Configuration
  2. Select Main Website as the Current Configuration Scope:
  3. Select Customer Configuration under Customers
  4. Under Create New Account Options and Password Options sections you can enable and setup the email templates.
  5. Save configurations.

OR Still you want to send any custom email at the mentioned situations, you can use event/observer to achieve this.


You can use the following code wherever you need to send the emails:

$customer = Mage::getSingleton('customer/session')->getCustomer();
$emailTemplateVariables = array(); 
$emailTemplateVariables['my_custom_message'] = 'you can have as many of these variables as you want - just add them to the array';
$emailTemplate  = Mage::getModel('core/email_template')->loadDefault('my_custom_email_template'); 
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->setTemplateSubject('Example Email Template');
$emailTemplate->send($customer->getEmail(), $customer->getName(), $emailTemplateVariables); 

You would access the variable 'my_custom_message' in the email template like this:

{{var my_custom_message}}

The template itself needs to be defined in your /app/etc/config.xml file, inside of the <resources> node. Enter the following just after the line </models>

            <label>My Custom Email Template</label>

and the finally, you need to create the email template file in /app/locale/en_US/template/email/my_custom_email_template.html (or whichever locale your store is using). You can duplicate one of the existing templates to give you a starting point.


The simplest way for editing this email would be to log into the admins section and go to System->Transactional Emails. They simply select Add new template and on the next page select from the drop down Template Forgotten Password.

You should then see the template loaded below and you can make any changes to the template you want there.

For full details please read the magento knowledge base


dan's code is what you need for sending the email. Create as many you want with that way.

But first you need to find the right events to listen to. For user registration there is the customer_register_success.

Use Alan's answer to find events for forget/reset password actions.

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