11 Jan 2014

Magento: How To Subscribe Customer Email Id To Newsletter Subscription List Automatically

Sometimes we need to auto subscribe the customer email address without knowing to customer if he visit to our site or click on any events in the site .So in magento that functionality is also available but that generally goes through customer permission .but here you can set by below code to newsletter subscription list .

Here I have an email Id which I am getting from creating events and I want subscribe the newsletter automatically .For that I need to follow the below coding.

$email =  ‘testemail@gmail.com’;
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
if($subscriber->getStatus() != Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED &&
        $subscriber->getStatus() != Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED) {