I would like to send an email notification to my store\'s contact email address every time when a new customer has been Registered.
I don\'t want to purchase any kin
It could be done perfectly with Magento event/ observer system. First of all, register your module.
app/etc/modules/Namespace_Modulename.xml
true
local
Than write a config file for it.
app/code/local/Namespace/Modulename/etc/config.xml
0.0.1
model
unic_class_group_name/observer
customerRegisterSuccess
Namespace_Modulename_Helper
Namespace_Modulename_Model
notify_new_customer.html
html
Here is a few things happened:
customer_register_success
(it's dispatched at line 335 in Mage_Customer_AccountController
) in frontend/events
node. It's better than using customer_save_after
, because the last one will fire every time customer is saved, not only when he is registered;global/template/email
node. To allow us to send a custom email with it.Next create an email template (file).
app/locale/en_US/template/notify_new_customer.html
Congratulations, a new customer has been registered:
Name: {{var name}}
Email: {{var email}}
...
After that define an observer method.
app/code/local/Namespace/Modulename/Model/Observer.php
class Namespace_Modulename_Model_Observer
{
public function customerRegisterSuccess(Varien_Event_Observer $observer)
{
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('notify_new_customer');
$emailTemplate
->setSenderName(Mage::getStoreConfig('trans_email/ident_support/name'))
->setSenderEmail(Mage::getStoreConfig('trans_email/ident_support/email'))
->setTemplateSubject('New customer registered');
$result = $emailTemplate->send(Mage::getStoreConfig('trans_email/ident_general/email'),(Mage::getStoreConfig('trans_email/ident_general/name'), $observer->getCustomer()->getData());
}
}
EDIT: as @benmarks pointed out this solution will not work if customer is registered during checkout. The solution to this behavior is described here. But, I think, it's better to use _origData
functionality as @benmarks suggested. So use his answer as guideline to achieve what you need.
Useful links: