2

I want to send attachment with newsletter in magento, I want to find, which file is using for sending newsletter email. I tried with this file /app/code/local/Mage/Newsletter/Model/Subscriber.php and add attachment code sendConfirmationRequestEmail in this function, but its not a write file. Can any one help ?

1 Answer 1

4

I found file in which I need to make change, its /app/code/local/Mage/Newsletter/Model/Queue.php and I just added code in sendPerSubscriber() function inside foreach loop

        foreach($collection->getItems() as $item) {
        $email = $item->getSubscriberEmail();
        $name = $item->getSubscriberFullName();

        $sender->emulateDesign($item->getStoreId());


        //sending file as attachment code start

            $fileName="PSB_ONLINE.pdf";//file to be attach                                          
            $attachmentFilePath = Mage::getBaseDir('media'). DS . $fileName;
            if(file_exists($attachmentFilePath)){
                $fileContents = file_get_contents($attachmentFilePath);                    
                $attachment   = $sender->getMail()->createAttachment($fileContents);
                $attachment->type = 'application/pdf';
                $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                $attachment->encoding = Zend_Mime::ENCODING_BASE64;                 
                $attachment->filename = $fileName;
                }
     //sending file as attachment end


        $successSend = $sender->send($email, $name, array('subscriber' => $item));
        $sender->revertDesign();

        if($successSend) {
            $item->received($this);
        } else {
            $problem = Mage::getModel('newsletter/problem');
            $notification = Mage::helper('newsletter')->__('Please refer to exeption.log');
            $problem->addSubscriberData($item)
                ->addQueueData($this)
                ->addErrorData(new Exception($notification))
                ->save();
            $item->received($this);
        }
    }
1
  • can you please accept your own question. Please do it friend. Nov 8, 2014 at 3:09

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.