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 BasicHeaders
extends BaseListener
{
18 * Inject basic headers
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 */
32 if ($task->hasContent()) {
36 list($verp) = $mailing->getVerpAndUrlsAndHeaders(
37 $e->getJob()->id
, $task->getEventQueueId(), $task->getHash(),
40 $mailParams = array();
41 $mailParams['List-Unsubscribe'] = "<mailto:{$verp['unsubscribe']}>";
42 \CRM_Mailing_BAO_Mailing
::addMessageIdHeader($mailParams, 'm', $e->getJob()->id
, $task->getEventQueueId(), $task->getHash());
43 $mailParams['Precedence'] = 'bulk';
44 $mailParams['job_id'] = $e->getJob()->id
;
46 $mailParams['From'] = "\"{$mailing->from_name}\" <{$mailing->from_email}>";
48 // This old behavior for choosing Reply-To feels flawed to me -- if
49 // the user has chosen a Reply-To that matches the From, then it uses VERP?!
50 // $mailParams['Reply-To'] = $verp['reply'];
51 // if ($mailing->replyto_email && ($mailParams['From'] != $mailing->replyto_email)) {
52 // $mailParams['Reply-To'] = $mailing->replyto_email;
55 if (!$mailing->override_verp
) {
56 $mailParams['Reply-To'] = $verp['reply'];
58 elseif ($mailing->replyto_email
&& ($mailParams['From'] != $mailing->replyto_email
)) {
59 $mailParams['Reply-To'] = $mailing->replyto_email
;
62 $task->setMailParams(array_merge(
64 $task->getMailParams()