Magento 1 Subscribe customer programatically

This can be done with one line of code:

$subscriber = Mage::getModel('newsletter/subscriber')->subscribe('customer@magentoguides.com');

Please note that this will send a confirmation email to the customer.

You can then find the new email in Backend > Newsletter > Newsletter Subscribers.

You can get subscribers collection with this snippet.

$collection = Mage::getModel('newsletter/subscriber')->getCollection()
                  ->setPageSize(10)
                  ->setOrder('subscriber_id', 'desc');

 


Lukas
Lukas Stranovsky
I am the guy who made this. Sorry for typos.