SmtpPlus for Magento Store Developers

SmtpPlus offers events that allow Store Developers to interact with the Email Sending Process:

Email Send (before)

This event is called before a email is being sent. Using this event allows to interact before the email is processed by Magento.

Event

smtpplus_email_send_before

Description

Is triggered before the email message is being processed and transmitted.

Models passed to Observer

email - Current Email Object of instance Mage_Core_Model_Email.

email_template - Current Email Template Object of instance Mage_Core_Model_Email_Template (for Transactional Emails).


Email Send (after)

This event is called after a email has been sent. Using this event allows to interact after the email is processed by Magento.

Event

smtpplus_email_send_after

Description

Is triggered after the email message has been processed and transmitted.

Models passed to Observer

email - Current Email Object of instance Mage_Core_Model_Email or Mage_Core_Model_Email_Template (for Transactional Emails).

email_template - Current Email Template Object of instance Mage_Core_Model_Email_Template (for Transactional Emails).

variables - Variables for the Message Header (Name, Email Address, Subject) for Transactional Emails.

message - Current Message Object of instance Zend_Mail.

exception - In case of a Exception during sending of the Message Object, will be instance of Zend_Exception, or if notices of SmtpPlus occur of instance Pisc_Smtpplus_Model_Email_Exception. False otherwise.

To add your own Observer to the Events, you may use the following code examples as guideline:

Your Extensions [config.xml]

<global>
   <events>
      <smtpplus_email_send_before>
         <observers>
            <yourobserver_event_email_before>
               <type>singleton</type>
               <class>Your_Extension_Model_Observer</class>
               <method>eventEmailProcessBefore</method>
            </yourobserver_event_email_before>
	 </observers>
      </smtpplus_email_send_before>
   </events>
</global>


Your Extensions [Observer.php]

class Your_Extension_Model_Observer
{
 
  /*
   * Event before processing download
   */
  public function eventEmailProcessBefore($observer)
  {
  	$email = $observer->getEvent()->getEmail();
  	$email_template = $observer->getEvent()->getEmailTemplate();
  	$message = $observer->getEvent()->getMessage();
  	$exception = $observer->getEvent()->getException();
 
  	// Do your own stuff with it here...
 
  }
 
}