In my website, I have an option to choose a file.
I want file to be mailed to a particular email-id.
Screenshot of the file upload screen
I want to have a button which should mail selected file to a particular email-id.
How can I achieve this ?
The code which is used to set attchment with mail.
$storeId = Mage::app()->getStore()->getId();
$translate = Mage::getSingleton('core/translate');
$transactionalEmail = Mage::getModel('core/email_template');
$filepath = COMPLETE_PATH_UPLOADED_FILE;
if(file_exists($filepath)
{
$transactionalEmail->getMail()
->createAttachment(
file_get_contents($filepath),
Zend_Mime::TYPE_OCTETSTREAM,
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
basename($uploadfilename)
);
}
$transactionalEmail->sendTransactional($templateId, $sender, OTHER_VARIABLES, $storeId);
$translate->setTranslateInline(true);