Listing 9.6: Overriding save() in our SupportTicket subclass to trigger email
class SupportMailer
{
public function send(Zend_Db_Table_Row_Abstract $supportTicket) A
{
$mail = new Zend_Mail();
$mail->setBodyText($supportTicket->body);
$mail->setFrom('system@example.com', 'The System');
$mail->addTo('support@example.com', 'Support Team');
$mail->setSubject(
strtoupper($supportTicket->type) . ': '
. $supportTicket->title);
$mail->send();
}
}
A The supportTicket is passed to the send function
The SupportTicket::save() method in listing 9.6 can now call our new mailing class and pass itself as
a parameter like so:
$id = parent::save();
SupportMailer::send($this);
With that done we can add some more of the functionality to the mail class itself.
9.3.3 Adding headers to the support email
The fourth requirement in our application specification was that an email be sent to ???all concerned???. It turns
out this does not mean just the support team at support@example.com. In fact what is needed is that all admin
users of the system are to be emailed and the submitter is to be cc??™d a copy as well. We also get the additional
request to add a priority indication that email clients like Outlook and Apple??™s Mail can recognise. Luckily
both of these are relatively easy and simply require working with email headers.
Pages:
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259