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 ?

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);
| improve this answer | |
  • I am not able to save the uploaded file, hence, not able to mail the same. – Rajat Agarwal Apr 10 '17 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. – Dhiren Vasoya Apr 11 '17 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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