2

Some of my customers have second email address as customer attribute. I would like to send an copy of every transactional email to customer second email address. I wonder - if magento have event which firing during transactional email sending?

2 Answers 2

6

There are unfortunately no events in the Mage_Core_Model_Email_Template and Mage_Core_Model_Email classes.

If you would like to extend the functionality to send to multiple customer e-mail addresses, the following could be a possible way for you:

  1. Rewrite Mage_Core_Model_Email_Template and Mage_Core_Model_Email

  2. Do only rewrite the send() function and put your own events in there.

For Mage_Core_Model_Email_Template it could look like this:

class Your_Module_Model_Core_Email_Template extends Mage_Core_Model_Email_Template {
/**
* wraps send() method of parent, supplies before and after events
*/
public function send($email, $name = null, array $variables = array())
{
    Mage::dispatchEvent('email_template_send_before', array('email' => $this, 'email_to' => $email));
    $return = parent::send($email, $name, $variables);
    Mage::dispatchEvent('email_template_send_after', array('email' => $this, 'email_to' => $email));
   return $return;
}

$email and $name can be an array (see the send() method in Mage_Core_Model_Email_Template).

Do it analog for Mage_Core_Model_Email.

  1. Use your newly created events to hook hin and add the customers second e-mail address.
1

This question might help you. There is an event called sales_order_place_after. Or you can create a rewrite for Mage_Sales_Model_Order::sendNewOrderEmail and add the CC there.

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.