If you want to be able to modify something in an observer you need to pass that variable to the observer as an object because objects are passed by reference and arrays are not.
So you can change this:
Mage::dispatchEvent('email_template_send_before', [
'email' => $email,
'email_to' => $name,
'variables' => $variables,
'template' => $this->getId()
]);
to this:
$observerData = [
'email' => $email,
'email_to' => $name,
'variables' => $variables,
'template' => $this->getId()
];
$object = new Varien_Object($observerData);
Mage::dispatchEvent('email_template_send_before', ['object'=>$object]);
Then, in your observer you can change the variables like this:
public function doSomething($observer)
{
$object = $observer->getEvent()->getObject();
$variables = $object->getVariables();
//change the value of $variables as you want here
//...
//then set the changed variables again to the original object
$object->setVariables($variables);
}
Then change the line
$returnVal = parent::send($email, $name, $variables);
to
$email = $object->getEmail();
$name = $object->getName();
$variables = $object->getVariables();
$returnVal = parent::send($email, $name, $variables);
In conclusion, your code should look like this:
$observerData = [
'email' => $email,
'email_to' => $name,
'variables' => $variables,
'template' => $this->getId()
];
$object = new Varien_Object($observerData);
Mage::dispatchEvent('email_template_send_before', ['object'=>$object]);
$email = $object->getEmail();
$name = $object->getName();
$variables = $object->getVariables();
$returnVal = parent::send($email, $name, $variables);
$afterObserverData = [
'email' => $email,
'email_to' => $name,
'variables' => $variables,
'return_value' => $returnVal
];
$afterObserverObject = new Varien_Object($afterObserverData);
Mage::dispatchEvent('email_template_send_after', ['object' => $afterObserverObject]);
For the last event dispatch there is no need to convert everything to an object but it might help you if you have additional code after the even dispatch that uses the same variables that are passed to the event.