Magento – Programmatically Subscribe and Unsubscribe Newsletter Subscribers

The following can be a handy snippet. Its usage and placement is totally up to your imagination and requirements.

/* To Subscribe */
Mage::getModel(‘newsletter/subscriber’)->subscribe(‘[email protected]’);
/* To Unsubscribe */
Mage::getModel(‘newsletter/subscriber’)->loadByEmail(‘[email protected]’)->unsubscribe();


2 responses to “Magento – Programmatically Subscribe and Unsubscribe Newsletter Subscribers”

  1. Magor Menessy

    still usefull in Magento 1.9.2 :) so thanks! but where would I add it?

    1. Darren Felton

      @magormenessy:disqus that’s highly dependent on your scenario. Are you looking to automatically subscribe people when they create an account? Do you simply have a list of emails you’d like to subscribe? Are you looking to subscribe someone after submitting a contact form? etc. etc.