0

Looking to change the 1.9.3.4 email system to allow for adding attachments.

Due to the nature of the attachment (dynamically generated PDF based on a variety of things, from customers/orders/3rd party) I would like to attach the PDF in this function:

queueNewOrderEmail

in this file:

/app/code/local/Mage/Sales/Model/Order.php

The changes to the email system in recent versions make finding info online extremely difficult.

It looks as though I should be creating the Zend attachment function in here:

/app/code/local/Mage/Core/Model/Email/Template.php

However, it looks as though the email queue system will ignore that.

This seems like it should be a quick and easy task, but I'm absolutely stumped at this point.

2
  • magento.stackexchange.com/questions/9652/…
    – Haim
    Commented Oct 31, 2018 at 17:06
  • @Haim thank you, but I don't see how that will work, as it requires a new extension and also much of that code looks to be for previous versions of Magento (which used a very different email process) Commented Oct 31, 2018 at 17:25

1 Answer 1

0

Not great, but I've got a workaround for now.

I've added the Zend file attachment stuff in this file,

/app/code/local/Mage/Core/Model/Email/Template.php

inside the send($email, $name = null, array $variables = array()) function.

$filename = $variables['filename']; 
$content = file_get_contents("/var/www/webroot/".$filename); 
//some additional work is done here to verify the file is legitimate/safe/etc.
$attachment = new Zend_Mime_Part($content);
$attachment->type = 'application/pdf';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = $filename;

This allows me to pass the file name from this file: /app/code/local/Mage/Sales/Model/Order.php

Inside queueNewOrderEmail($forceMode = false)

$mailer->setTemplateParams(array(
                  'order'        => $this,
                  'billing'      => $this->getBillingAddress(),
                  'payment_html' => $paymentBlockHtml,
                  'customMessage' => $message,
                  'filename' => $filename
              )
          );

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.