1

I have implemented "full product lising" page with all the products in all categories (With approximately 200 products, varies on adding new products). This is in a tabular format which has only two columns:

  1. Project Name
  2. Price

And I have implemented dynamic generation of pdf with all these 200 products.

Now my requirement is to send this pdf in an email to the specified email address. How can i do with magento? Do i need to create new email template with pdf attachment?

Please suggest a best solution.

3

Try this:

  $oEmailTemplate = Mage::getModel('core/email_template')->loadDefault('email_template');
  $oMail = $oEmailTemplate->getMail();
  $oAttachment = $oMail->createAttachment(
        file_get_contents($sPdfSrc),
        Zend_Mime::TYPE_OCTETSTREAM,
        Zend_Mime::DISPOSITION_ATTACHMENT,
        Zend_Mime::ENCODING_BASE64,
        basename($sPdfSrc)
  );
1

Have a look at Zend_Mail.

https://github.com/LokeyCoding/magento-mirror/blob/magento-1.8/lib/Zend/Mail.php

You'll find it has everything you need to send mail from, say, your own controller or other module class.

Depending on what you're doing, you also could extend from a number of Magento classes that have mail sending methods. Have a look at Mage_Core_Model_Email_Template and you'll find there are some things to help integrate with Magento, but ultimately they just call Zend_Mail.

1

You can see how did I do that in this extension. Check app/code/local/Comwrap/InvoiceEmails/Model/Mailer.php and app/code/local/Comwrap/InvoiceEmails/Model/Observer.php.

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.