{"id":2293,"date":"2023-09-28T07:30:30","date_gmt":"2023-09-28T07:30:30","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/magento-newsletter-unsubscribe-link-not-working\/"},"modified":"2025-05-21T16:45:19","modified_gmt":"2025-05-21T11:15:19","slug":"magento-newsletter-unsubscribe-link-not-working","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/magento-newsletter-unsubscribe-link-not-working\/","title":{"rendered":"Solved: Magento Newsletter Unsubscribe Link Not Working"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Sending a newsletter is imperative for any e-commerce brand to improve its brand awareness and keep your shoppers engaged to your store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here the email service provider expects you, as the sender of emails, to include an unsubscribe or unsubscription link in your email to keep the user\u2019s experience intact. And give the users the convenience of easily opting out of your email list if they are not interested.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At times, as a&nbsp;<a href=\"https:\/\/business.adobe.com\/in\/products\/magento\/magento-commerce.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2<\/a>&nbsp;store owner, the hurdle of your&nbsp;<em><strong>Magento Newsletter Unsubscribe Link Not Working<\/strong><\/em>&nbsp;can get hectic and can also leave your shoppers frustrated.&nbsp; In this blog, I will explain how to create a custom module to add newsletter unsubscribe link and pass it easily.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution: Magento Newsletter Unsubscribe Link Not Working<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In order to&nbsp;implement the unsubscription link, here will you have to override two core classes in Magento:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MagentoNewsletterModelTemplate<\/li>\n\n\n\n<li>MagentoNewsletterModelQueue<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">By extending these two classes, you will be able to make the necessary changes in your newsletter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let us take a look at each class closely.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"template\">Template.php<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the Template.php file, extend the MagentoNewsletterModelTemplate class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this method, add the unsubscription link by setting the template text and add the variable {{var subscriber.unsubscriptionLink}}.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  if (!$this->getData('template_text') &amp;&amp; !$this->getId()) {\n            $this->setData(\n                'template_text',\n                __(\n                    'Follow this link to unsubscribe &lt;!-- This tag is for unsubscribe link -->' .\n                    '{{var subscriber.unsubscriptionLink}}' .\n                    ''\n                )\n            );\n        }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This variable ensures that each email has a&nbsp;<strong>unique unsubscription link for each email you send to your subscribers<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now moving to the next step.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"queue\">Queue.php<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the Queue.php file method, you will have to extend the MagentoNewsletterModelQueue class. In this method, you will be adding the link to your&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/configure-magento-2-email-header-template\/\">email template<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> $item-&gt;setData('unsubscriptionLink', $item-&gt;getUnsubscriptionLink());<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code ensures that the link gets included in every email you send and that it works effectively.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&amp; that\u2019s it!  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This way, you can send a newsletter with an unsubscription link to avoid unexpected errors when a shopper tries to opt-out. I hope this solution helps you solve this issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And if liked this Magento newsletter unsubscribe link not working solution, consider sharing it on your social media and with any Magento community you might be a part of.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you for reading!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sending a newsletter is imperative for any e-commerce brand to improve its brand awareness and keep your shoppers engaged to your store. Here the email&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2293","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2293"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2293\/revisions"}],"predecessor-version":[{"id":13829,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2293\/revisions\/13829"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}