Skip to content

Commit

Permalink
newsletter/template add before/after events
Browse files Browse the repository at this point in the history
  • Loading branch information
rjocoleman committed Jan 30, 2021
1 parent 4738d6c commit 043e154
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/code/core/Mage/Newsletter/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,29 @@ public function send($subscriber, array $variables = array(), $name = null, Mage
$mail->setFrom($this->getTemplateSenderEmail(), $this->getTemplateSenderName());

try {
$mail->send();
$transport = new Varien_Object();

Mage::dispatchEvent('newsletter_send_before', array(
'mail' => $mail,
'transport' => $transport,
'template' => $this,
'subscriber' => $subscriber
));

if ($transport->getTransport()) {
$mail->send($transport->getTransport());
} else {
$mail->send();
}

Mage::dispatchEvent('newsletter_send_after', array(
'to' => $email,
'html' => !$this->isPlain(),
'queue' => $queue,
'subject' => $mail->getSubject(),
'email_body' => $text
));

$this->_mail = null;
if (!is_null($queue)) {
$subscriber->received($queue);
Expand Down

0 comments on commit 043e154

Please sign in to comment.