I am working on a functionality to send mass mail on product update.I want to improve code for performance and to avoid spam.


 $collection = Mage::getModel('newsletter/subscriber')->getCollection();
 $arr = array();

   foreach ($collection as $subscriber) 
      $arr[] = $subscriber->getData();

    $html = '<strong>Dear Subscriber,</strong><br>
                    Following product has been updated <br><br> ';

         $mail = Mage::getModel('core/email')
             ->setSubject('Sarees Images Collection')
             ->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email', $storeId))

             catch(Exception $error)
             return false;


Though mails are being sent to susbscribers it is slowing the page and there is a fear of being spammed.

How can I tackle this?

I am using Magento ver.


Using the webserver where you host your website for bulk mailing is not a very good idea. Spamfilters will add you to blacklists which could eventually harm your website in unexpected ways.

If you want to send bulk emails from your magento use an Email provider instead. They have dedicated teams to stay out of spamboxes so you don't have to worry about that anymore. There are plenty free solutions like Sendgrid, Mailchimp (trough Mandrill) and Mailgun. Mailgun is developers oriented, so that might be a good choice.

Check a roundup here.

  • ok..if I hv around 500 email addresses,how can I improve the code esp. loop part? Jul 27 '16 at 13:11
  • If it is slowing pageload too much you could consider it moving it to solving it with a cronjob? Write code which does a check who should be email when cronjob is running.
    – Akif
    Jul 27 '16 at 13:17
  • You mean in batch process? Jul 27 '16 at 13:36
  • Yes, see example here: inchoo.net/magento/creating-cron-script-in-magento
    – Akif
    Jul 28 '16 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.