i want use this code for send email to authors of article after adding comment , where should i use this code ?
$cdd_article =& JTable::getInstance('content');
$cdd_article->load(JRequest::getInt('id'));
$cdd_authorid = $cdd_article->created_by;
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__users WHERE id = " . $cdd_authorid ;
$db->setQuery($query);
$cdd_contact = $db->loadAssoc();
$cdd_email = $cdd_contact['email'];
$cdd_name = $cdd_contact['name'];
$cmm=$comment->comment;
$mailer =& JFactory::getMailer();
$config =& JFactory::getConfig();
$sender = array(
$config->getValue( 'config.mailfrom' ),
$config->getValue( 'config.fromname' ) );
$mailer->setSender($sender);
$recipient = $cdd_email;
$mailer->addRecipient($recipient);
$body = "کاربر گرامي $cdd_name\n يک نظر جديد در مورد مطلب شما به ثبت رسيده است \n لطفا جهت بازديد از آن به سايت مراجعه کنيد\n www.tejaratekharegi.com";
$mailer->setSubject('کاربر گرامي شما يک نظر جديد دريافت کرديد');
$mailer->setBody($body);
$send =& $mailer->Send();