0

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

upload screen

I want to have a button which should mail selected file to a particular email-id.

How can I achieve this ?

1 Answer 1

0

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);
2
  • I am not able to save the uploaded file, hence, not able to mail the same. Commented Apr 10, 2017 at 13:38
  • @RajatAgarwal have done any code to save the selected file in particular place when button is clicked? In no, then you need to do that thing first. Commented Apr 11, 2017 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.