diff --git a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php index 092bd6d89e..bf5ac1252b 100644 --- a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php +++ b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php @@ -75,11 +75,8 @@ class Unsubscribe extends \Espo\Core\EntryPoints\Base $link = $m[$target->getEntityType()]; } if ($link) { - if ($campaign) { - $targetListList = $campaign->get('targetLists'); - } else { - $targetListList = $massEmail->get('targetLists'); - } + $targetListList = $massEmail->get('targetLists'); + foreach ($targetListList as $targetList) { $this->getEntityManager()->getRepository('TargetList')->updateRelation($targetList, $link, $target->id, array( 'optedOut' => true