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
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:
Rewrite
Mage_Core_Model_Email_TemplateandMage_Core_Model_EmailDo 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.
- Use your newly created events to hook hin and add the customers second e-mail address.
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.