Try This
app/code/VendoreName/ModuleName/etc
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Newsletter\Model\Queue" type="VendoreName\ModuleName\Model\Queue" />
<preference for="Magento\Newsletter\Model\Template" type="VendoreName\ModuleName\Model\Template" />
</config>
app/code/VendoreName/ModuleName/Model
Queue.php
<?php
namespace VendoreName\ModuleName\Model;
class Queue extends \Magento\Newsletter\Model\Queue
{
/**
* Send messages to subscribers for this queue
*
* @param int $count
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function sendPerSubscriber($count = 20)
{
if ($this->getQueueStatus() != self::STATUS_SENDING &&
($this->getQueueStatus() != self::STATUS_NEVER &&
$this->getQueueStartAt())
) {
return $this;
}
if (!$this->_subscribersCollection->getQueueJoinedFlag()) {
$this->_subscribersCollection->useQueue($this);
}
if ($this->_subscribersCollection->getSize() == 0) {
$this->_finishQueue();
return $this;
}
$collection = $this->_subscribersCollection->useOnlyUnsent()->showCustomerInfo()->setPageSize(
$count
)->setCurPage(
1
)->load();
$this->_transportBuilder->setTemplateData(
[
'template_subject' => $this->getNewsletterSubject(),
'template_text' => $this->getNewsletterText(),
'template_styles' => $this->getNewsletterStyles(),
'template_filter' => $this->_templateFilter,
'template_type' => self::TYPE_HTML,
]
);
/** @var \Magento\Newsletter\Model\Subscriber $item */
foreach ($collection->getItems() as $item) {
$transport = $this->_transportBuilder->setTemplateOptions(
['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $item->getStoreId()]
)->setTemplateVars(
[
'subscriber' => $item,
'subscriber_data' => [
'unsubscription_link' => $item->getUnsubscriptionLink(),
],
]
)->setFrom(
['name' => $this->getNewsletterSenderName(), 'email' => $this->getNewsletterSenderEmail()]
)->addTo(
$item->getSubscriberEmail(),
$item->getSubscriberFullName()
)->getTransport();
try {
$transport->sendMessage();
} catch (\Magento\Framework\Exception\MailException $e) {
/** @var \Magento\Newsletter\Model\Problem $problem */
$problem = $this->_problemFactory->create();
$problem->addSubscriberData($item);
$problem->addQueueData($this);
$problem->addErrorData($e);
$problem->save();
}
$item->received($this);
}
if (count($collection->getItems()) < $count - 1 || count($collection->getItems()) == 0) {
$this->_finishQueue();
}
return $this;
}
}
app/code/VendoreName/ModuleName/Model
Template.php
<?php
namespace VendoreName\ModuleName\Model;
class Template extends \Magento\Newsletter\Model\Template
{
/**
* Retrieve template text wrapper
*
* @return string
*/
public function getTemplateText()
{
if (!$this->getData('template_text') && !$this->getId()) {
$this->setData(
'template_text',
__(
'Follow this link to unsubscribe <!-- This tag is for unsubscribe link -->' .
'<a href="{{var subscriber_data.unsubscription_link}}">Unsubscribe' .
'</a>'
)
);
}
return $this->getData('template_text');
}
}
Use in Newslatter Email Template : <a href="{{var subscriber_data.unsubscription_link}}">Unsubscribe</a>
Reference Link : https://github.com/magento/magento2/pull/33753