3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
11 namespace Civi\FlexMailer\Listener
;
13 use Civi\FlexMailer\Event\ComposeBatchEvent
;
15 class BounceTracker
extends BaseListener
{
18 * Inject bounce-tracking codes.
20 * @param \Civi\FlexMailer\Event\ComposeBatchEvent $e
22 public function onCompose(ComposeBatchEvent
$e) {
23 if (!$this->isActive()) {
27 $mailing = $e->getMailing();
29 foreach ($e->getTasks() as $task) {
30 /** @var \Civi\FlexMailer\FlexMailerTask $task */
31 list($verp) = $mailing->getVerpAndUrlsAndHeaders(
32 $e->getJob()->id
, $task->getEventQueueId(), $task->getHash(),
35 if (!$task->getMailParam('Return-Path')) {
36 $task->setMailParam('Return-Path', $verp['bounce']);
38 if (!$task->getMailParam('X-CiviMail-Bounce')) {
39 $task->setMailParam('X-CiviMail-Bounce', $verp['bounce']);