Wednesday, 22 August 2012

How to send newsletter manually / programmatically to customer

I hope this helps  !!!!!!!!!


/*************** This code returns all subscribers  ***************/
$collection = $objCol;
/*************** Load the newsletter template model by $templateId   *******/
$tmplt=Mage::getModel('newsletter/template')->load($templateId); $message=$tmplt->getTemplateText(); foreach($collection->getItems() as $item) { $email = $item->getSubscriberEmail(); $name = $item->getSubscriberFullName(); try{ $mail = new Zend_Mail(); $mail->setFrom($tmplt->getTemplateSenderEmail()); $mail->setBodyHtml($message); $mail->addTo($email, 'recipient'); $mail->setSubject($tmplt->getTemplateSubject()); $mail->send(); echo "Newsletter sent to ".$email."<br>"; } catch(Exception $e) { echo $e->getMessage(); } } ?>

If this helps, please comment on this post and like or share this on linkedin, facebook. 
Enjoy :-)   !!!!!!!!

1 comment:

  1. Thanks a bunch for sharing this with all people you actually recognize what you are talking about! Bookmarked. Kindly also discuss with my website.
    Certified Magento Developer