|send email from a model class [message #102495]
||Wed, 14 July 2010 23:18
Registered: June 2010
I want to send an email everytime the staut of an order is modified in the backend.
I made something like this:
public function preSave($event)
$modified = $event->getInvoker()->getModified(true);
// whether or not the status has changed
if ($this->getStatutId() == 2)
$mail = sfContext::getInstance()->getMailer()->compose();
I read that it's bad to use sfContext::getInstance() http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is -bad/.
My questions are:
It is the best way to do what I want?
How can I send email without using sfContext::getInstance() ?
Is there anyway to read a partial from a model class (something like $this->getPartial used in action)