1

There is a "header" entry automatically put into mailnigs from civimail (also when using flexmailer / mosaico) which some email clients use to enable unsubscribing (or opting out) from mailing lists.

If, for example, an unsubscribe link is in your email, and the site is reporting opt-out's (or vice-versa) then this may be the reason why. So - how to fix it?

1 Answer 1

2

thanks to @pradpnayak for guidance :D

according to the docs for hook_civicrm_alterMailParams:

You can add custom headers by appending to $params['headers']. Example:

$params['headers']['X-My-Header'] = 'my header value';

The headers key may not exist in the $params array when passed into the > hook.

so this was the code in an extension to unset the existing 'List-Unsubscribe', and put in a NULL replacement into the headers:

/**
 * Implements hook_civicrm_alterMailParams().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
 */
function custom_civicrm_alterMailParams(&$params, $context) {
  if ($context == 'flexmailer' || $context == 'civimail') {
    // remove existing header
    unset($params['List-Unsubscribe']);
    // replace via the 'headers' key
    $params['headers']['List-Unsubscribe'] = NULL;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.