4

We set the option that a user needs to confirm their subscription to yes.
In System > Configuration > Newsletter > Need to confirm **(YES)**

That works good, but when a user did confirm his/her email address, they do not receive the Success Email.

How can we send the Succes Email after they confirmed their email address?

7

Search the file /app/code/core/Mage/Newsletter/Model/Subscriber.php

copy the whole content to

MyVendor/Tweaks/Newsletter/Model/Subscriber.php

Then find the below

public function confirm($code)
    {
        if($this->getCode()==$code) {
            $this->setStatus(self::STATUS_SUBSCRIBED)
                ->setIsStatusChanged(true)
                ->save();
            return true;
        }
        return false;
    }

And replace it with:

public function confirm($code)
    {
        if($this->getCode()==$code) {
            $this->setStatus(self::STATUS_SUBSCRIBED)
                ->setIsStatusChanged(true)
                ->save();

                $this->sendConfirmationSuccessEmail();
            return true;
        }

        return false;
    }
  • 1
    Commenting for posterity... it is better practice to put this sort of update in a module. Editing app/code/core directly 1) may have unintended consequences, and 2) can complicate the installation of security patches. Instead, you could make MyVendor/Tweaks/ and extend the Mage/Newsletter/Model/Subscriber.php to create MyVendor/Tweaks/Newsletter/Model/Subscriber.php. Check out this similar thread. – nshiff Feb 13 '17 at 15:50
  • how it do for magento 2???? – sam Jul 24 '17 at 6:46
  • This solution is not working for me... :-( I override the Mage_Newsletter_Model_Subscriber and try this solution but it does not work – Stefanos Oct 9 '17 at 13:21
1

Klettseb's solution should work, but I'd recommend a lighter approach instead of overriding the entire Subscriber class:

\app\etc\modules\Yourcompany_Newsletter.xml

  <?xml version="1.0"?>
  <config>
      <modules>
          <Yourcompany_Newsletter>
              <active>true</active>
              <codePool>local</codePool>
              <version>1.0.0</version>
          </Yourcompany_Newsletter>
      </modules>
  </config>

\app\code\local\Yourcompany\Newsletter\etc\config.xml

 <?xml version="1.0" encoding="UTF-8"?>
  <config>
      <modules>
          <Yourcompany_Newsletter>
              <version>1.0.0</version>
          </Yourcompany_Newsletter>
      </modules>
      <global>
          <models>
              <yourcompany_newsletter>
                  <class>Yourcompany_Newsletter_Model</class>
              </yourcompany_newsletter>
              <newsletter>
                  <rewrite>
                     <subscriber>Yourcompany_Newsletter_Model_Subscriber</subscriber>
                  </rewrite>
              </newsletter>
          </models>
      </global>
  </config>

\app\code\local\Yourcompany\Newsletter\Model\Subscriber.php

  <?php

  class Yourcompany_Newsletter_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
  {

      /**
       * send the confirmation-success email if newsletter subscription is confirmed
       */
      public function confirm($code)
      {
          $isConfirmed = parent::confirm($code);

          if ($isConfirmed == true) {
              $this->sendConfirmationSuccessEmail();
          }

          return $isConfirmed;
      }

  }

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.