Magento add attachment to email

Hello All,
I have found working code to send email with attachment.

$attachmentFilePath = Mage::getBaseDir('media'). DS.$filpath; //filepath is path of file inside media directory
$mailTemplate = Mage::getModel('core/email_template');
if(file_exists($attachmentFilePath)){ 
                    $fileContents = file_get_contents($attachmentFilePath);
                    $attachment   = $mailTemplate->getMail()->createAttachment($fileContents,Zend_Mime::TYPE_OCTETSTREAM,Zend_Mime::DISPOSITION_ATTACHMENT,Zend_Mime::ENCODING_BASE64,basename($attachmentFilePath));
              
                }

$postObject = new Varien_Object();
//Below code require you understandtsthe term used
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
                    ->setReplyTo($post['email'])
                    ->sendTransactional(
                        $template_id,  //template id of email template
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                        null,
                        array('data' => $postObject)
    );