1

I need to send a copy of the forgot password email to a particular email address every time on forgot password attempts. Is there way to configure this in magento ?

2 Answers 2

2

It would be bad practice to do this as passwords are meant to be secure. However if you insist on following this through, you would have a few approaches.

Mail Server Configuration

Some mail servers can be configured to handle this from their configuration. This of course assumes that you have server administrator rights to the mail service.

Magento Customisations

If you follow the customer account forgot password controller path, you will be lead to the method sendPasswordResetConfirmationEmail() within the customer model, Mage_Customer_Model_Customer. If you override this you can customise the logic that will be sent out including adding your own BCC header.

2
  • thanks so as its a bad practice can we be sure that magento will not provide a configuration for doing this ?
    – ted
    Commented Jul 3, 2015 at 8:32
  • BTW we are not sending password but password reset links
    – ted
    Commented Jul 3, 2015 at 8:37
1

if you see the function sendPasswordResetConfirmationEmail() in Mage_Customer_Model_Customer class you will find the following code

$this->_sendEmailTemplate(self::XML_PATH_FORGOT_EMAIL_TEMPLATE, self::XML_PATH_FORGOT_EMAIL_IDENTITY,
            array('customer' => $this), $storeId);

so try to override _sendEmailTemplate() function of the same class i.e Mage_Customer_Model_Customer

and add following code in it

protected function _sendEmailTemplate($template, $sender, $templateParams = array(), $storeId = null)
        {
            /** @var $mailer Mage_Core_Model_Email_Template_Mailer */
            $mailer = Mage::getModel('core/email_template_mailer');
            $emailInfo = Mage::getModel('core/email_info');
            $emailInfo->addTo($this->getEmail(), $this->getName());

            if($template == 'customer/password/forgot_email_template'){
                /* email ids */
                $bcc = array("[email protected]","[email protected]");
                $emailInfo->addBcc($bcc);
                /* email ids */ 
            }
            $mailer->addEmailInfo($emailInfo);

            // Set all required params and send emails
            $mailer->setSender(Mage::getStoreConfig($sender, $storeId));
            $mailer->setStoreId($storeId);
            $mailer->setTemplateId(Mage::getStoreConfig($template, $storeId));
            $mailer->setTemplateParams($templateParams);
            $mailer->send();
            return $this;
        }

Edited:- Now i added a conditon if($template == 'customer/password/forgot_email_template'){} which will only send mail to bcc if the request is forgotpassword.

Note:- but this is bad because you will get passwords in your email of your customers

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.