iFuel is Now Part of the Amsive Family! Read More

Programmatically Subscribing a Customer to the Newsletter List

Recently we had to import a list of newsletter subscribers into Magento. We had already loaded all the customers, but now we needed to subscribe all of the customers that had subscribed on the customer’s old site on the new. The following code (simplified for display here) did the trick!



$email = “[email protected]”;

// THE “EASY” WAY (but sends a confirmation email to the customer
$subscriber = Mage::getModel(‘newsletter/subscriber’)->subscribe($email);

// THE “HARD” WAY (Doesn’t send confirmation email to customer)
// load up the customer we want to subscribe
$customer = Mage::getModel(‘customer/customer’)

// if we found the customer
if ($customer->getId()){
// load up the subscriber if possible
$subscriber = Mage::getModel(‘newsletter/subscriber’)->loadByEmail($email);

if (!$subscriber->getId()
|| $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED
|| $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {



try {
catch (Exception $e) {
throw new Exception($e->getMessage());


5 Responses to “Programmatically Subscribing a Customer to the Newsletter List”

  1. Hi, here a mutch easier soluntion:


    # get just generated subscriber
    $subscriber = Mage::getModel(‘newsletter/subscriber’)->loadByEmail($email);

    # change status to “subscribed” and save

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

[instagram-feed width=100 height=250 cols=5 num=5 showheader=false showbutton=false showfollow=false imagepadding=0]