1

For various reasons I am currently forced to work in: /app/code/local/Mage/Sales/Order.php

I know it's not ideal, but it's required at the moment.

in public function queueNewOrderEmail, I am looking to attach a file to the email that is being sent here.

I have tried:

$mailer->addAttachment(
                file_get_contents($attachment),
                'filename.pdf"
            );

and

$mailer->getMail()->createAttachment(
              file_get_contents($file),
              'application/pdf',
              Zend_Mime::DISPOSITION_ATTACHMENT,
              Zend_Mime::ENCODING_BASE64,
              basename($file)
          );

and

 $mailer->createAttachment(
                  file_get_contents($file),
                  'application/pdf',
                  Zend_Mime::DISPOSITION_ATTACHMENT,
                  Zend_Mime::ENCODING_BASE64,
                  basename($file)
              );

Error is:

exception 'Varien_Exception' with message 'Invalid method Mage_Core_Model_Email_Template_Mailer::createAttachment [truncated]

So this kinda makes sense... I guess Mage_Core_Model_Email_Template_Mailer can't use everything available in Zend... but how do I attach an email here? I am trying to avoid completely rewriting the function?

edit: file_get_contents() works when I create a separate PHP script. The file in question is rather large (12mb).

  • Verify that are you able to get content from specifyed file in above code? – Dhiren Vasoya Oct 28 '17 at 6:11
  • Your error is because function createAttachment doesn't exist in app/code/core/Mage/Core/Model/Email/Template/Mailer.php. You might be able to extend app/code/core/Mage/Core/Model/Email/Template.php .. – Ricky Odin Matthews Oct 30 '17 at 13:42
  • @RickyOdinMatthews are you able to expand on this at all? I am trying to solve this same problem. – user1988065 Oct 30 '18 at 19:23
  • @user1988065 so go into app/etc/modules/ and rename any non-Magento core modules to .xml.off, clear cache. If runs faster, one of the custom modules is the issue – Ricky Odin Matthews Oct 30 '18 at 20:45

Your Answer

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

Browse other questions tagged or ask your own question.