# One click unsubscribe header - full "do not contact" is excessive

**URL:** <https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560>\
**Category:** Ideas and Feature Requests\
**Created:** [December 30, 2024, 1:18pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560 "2024-12-30T13:18:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldev](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@ldev](https://forum.mautic.org/u/ldev)\
**Post date:** [December 30, 2024, 1:18pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/1 "2024-12-30T13:18:33Z")

</div>

Regarding the one-click unsubscribes.

Mautic handles them by setting “Do not contact” which stops all the communications.

But If I have multiple newsletters/segments - I just want to unsubscribe that consumer from **just that one newsletter** , not the entirety of mailings.

**What I’ve tried as a workaround:**

I’ve implemented my own unsubscribe page - and was hoping to simply override the List-Unsubscribe header so one-click unsubscribes go to my custom page and then my logic would simply remove them from just that one newsletter.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/9/955a4ac66b2eec86775fdddf8a4a9306dcd4dc75.png)

**I’ve hit multiple problems:**

a) There is a bug(or a feature?) in custom headers code - which mangles (or sanitizes) urls - is that by design?:

> <https://github.com/mautic/mautic/issues/13387>
>
> \### Mautic Version
> 
> 5.0.x series
> 
> \### Way of installing
> 
> Other (please spe…cify if relevant in the bug report)
> 
> \### PHP version
> 
> 8.0.30
> 
> \### What browsers are you seeing the problem on?
> 
> Chrome
> 
> \### What happened?
> 
> When adding a JSON string as a custom email header value the value ends up being encoded in the config file. On every save, the value is encoded again, resulting in an ever growing string.
> 
> For example, I want to create a custom email header with the following value...
> 
> \`{{"options": {"transactional": false, "ip\_pool": "default", "open\_tracking": true, "click\_tracking": true}}\`
> 
> On first save, the value is stored as...
> 
> \`{{&#34;options&#34;: {&#34;transactional&#34;: false, &#34;ip\_pool&#34;: default, &#34;open\_tracking&#34;: true, &#34;click\_tracking&#34;: true}}\`
> 
> On second save...
> 
> \`{{&#38;#34;options&#38;#34;: {&#38;#34;transactional&#38;#34;: false, &#38;#34;ip\_pool&#38;#34;: default, &#38;#34;open\_tracking&#38;#34;: true, &#38;#34;click\_tracking&#38;#34;: true}}\`
> 
> On third save...
> 
> \`{{&#38;#38;#34;options&#38;#38;#34;: {&#38;#38;#34;transactional&#38;#38;#34;: false, &#38;#38;#34;ip\_pool&#38;#38;#34;: default, &#38;#38;#34;open\_tracking&#38;#38;#34;: true, &#38;#38;#34;click\_tracking&#38;#38;#34;: true}}\`
> 
> ... and so on.
> 
> Not sure how to properly fix it, but commenting out the mailer\_custom\_headers line below in the file "app/bundles/EmailBundle/Form/Type/ConfigType.php" is a quick interim fix...
> 
> \`\`\`
> $builder-\>addEventSubscriber(
> new CleanFormSubscriber(
> \[
> 'mailer\_from\_email' =\> 'email',
> 'mailer\_return\_path' =\> 'email',
> 'default\_signature\_text' =\> 'html',
> 'unsubscribe\_text' =\> 'html',
> 'unsubscribe\_message' =\> 'html',
> 'resubscribe\_message' =\> 'html',
> 'webview\_text' =\> 'html',
> // Encode special chars to keep congruent with Email entity custom headers
> //'mailer\_custom\_headers' =\> 'clean',
> \]
> )
> );
> \`\`\`
>         
>  
> 
> \### How can we reproduce this issue?
> 
> Step 1: Attempt to save the following JSON string as a value in a custom email header \`{{"options": {"transactional": false, "ip\_pool": "default", "open\_tracking": true, "click\_tracking": true}}\`
> 
> \### Relevant log output
> 
> \_No response\_
> 
> \### Code of Conduct
> 
> \- \[X\] I confirm that I have read and agree to follow this project's Code of Conduct
> 
> \<br /\>\<hr\>
> Care about this issue? Want to get it resolved sooner? If you are a \<a href='https://www.mautic.org/become-a-member-of-mautic'\>member of Mautic\</a\>, you can add some funds to the \<a href='https://opencollective.com/mautic/projects/bounties'\>Bounties Project\</a\> so that the person who completes this task can claim those funds once it is merged by a member of the core team! Read the docs \<a href='https://contribute.mautic.org/product-team/mautic-bounty-programme'\>here.\</a\>

b) But even if I can inject my own one click unsubscribe link - Mautic adds it’s own one click unsubscribe url no matter what (which still causes DNC mark) :

```auto
$listUnsubscribeHeader = $this->getUnsubscribeHeader();
if ($listUnsubscribeHeader) {
    if (!empty($headers['List-Unsubscribe'])) {
        if (!str_contains($headers['List-Unsubscribe'], $listUnsubscribeHeader)) {
            // Ensure Mautic's is always part of this header
            $headers['List-Unsubscribe'] = $listUnsubscribeHeader.','.$headers['List-Unsubscribe'];
        }
    } else {
        $headers['List-Unsubscribe'] = $listUnsubscribeHeader;
    }
    $headers['List-Unsubscribe-Post'] = 'List-Unsubscribe=One-Click';
}

```

I’m not sure I understand the logic in always injecting mautic unsubscribe link, if I specifically intentionally configure my own `List-Unsubscribe` header ?

I can easily send a PR allowing full List-Unsubscribe overrides, ex:

```auto
if (!empty($headers['List-Unsubscribe'])) {
  if (!str_contains($headers['List-Unsubscribe'], $listUnsubscribeHeader)) {
    // Ensure Mautic's is always part of this header
    $headers['List-Unsubscribe'] = $listUnsubscribeHeader.','.$headers['List-Unsubscribe'];
  }
} else {
  $headers['List-Unsubscribe'] = $listUnsubscribeHeader;
}

```

to this:

```auto
if (empty($headers['List-Unsubscribe'])) {
  $headers['List-Unsubscribe'] = $listUnsubscribeHeader;
}

```

> <https://github.com/mautic/mautic/commit/f8ed9c73aa077e7016024b2681ff4e6cbe580cac>

> <https://github.com/mautic/mautic/commit/b227a18fb6a8bec6f1dbfe5b98cc06a66d40ad9e>

> <https://github.com/mautic/mautic/commit/f8ce7d3d65e3d030f6a33ca2018a2be5f93b72ed>
>
> \* fix: \[DPMMA-2588\] change list-unsubsribe values order
> 
> \* fix: \[DPMMA-2588\] M…ailHelper usubscribe parameter order test
> 
> \* fix: \[DPMMA-2588\] mail tests fix

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [December 30, 2024, 1:36pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/2 "2024-12-30T13:36:39Z")

</div>

Hello,  
Thank you for sharing this. It addresses a very real issue.  
Would your solution unsubscribe the person based on segment membership? Remove the person from that segment?

Joey

---

<div class="post-metadata">

**Author:** ![ldev](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@ldev](https://forum.mautic.org/u/ldev)\
**Post date:** [December 30, 2024, 3:11pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/3 "2024-12-30T15:11:01Z")

</div>

> Would your solution unsubscribe the person based on segment membership? Remove the person from that segment?

yes. I coded a wp plugin where unsubscribe link just takes a person to a wordpress site page which then removes them from a segment/segments and shows some “sorry to see you go message”. (using mautic api)

which is - it works fine as a link in the email. but then this “one click unsubscribe header” - also needs to be addressed for consistency.

---

<div class="post-metadata">

**Author:** ![ldev](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@ldev](https://forum.mautic.org/u/ldev)\
**Post date:** [December 30, 2024, 3:26pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/4 "2024-12-30T15:26:58Z")

</div>

re: wp plugin.

I think it could really draw people to use mautic more - because there is nothing low-cost for newsletters/new post notifications in wordpress world.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [December 30, 2024, 4:00pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/5 "2024-12-30T16:00:03Z")

</div>

But one click unsubscribe happens also programatically without page views.  
Gmail shows the ‘Unsubscribe’ link at the top of the email, and fires the one click unsubscribe in the background - server to server.  
A proper “ok 200” answer is needed here to be compliant.  
Joey

---

<div class="post-metadata">

**Author:** ![ldev](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@ldev](https://forum.mautic.org/u/ldev)\
**Post date:** [December 30, 2024, 4:17pm UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/6 "2024-12-30T16:17:52Z")

</div>

yes - http GET request that returns 200. my plugin supports that no issues.

which btw - mautic 5.2.1 appears to have issues with that, just reported a bug:  
[Instant unsubscribe link ends up in "500 Internal Server Error" · Issue #14419 · mautic/mautic · GitHub](https://github.com/mautic/mautic/issues/14419) - it responds as 500 instead to one click unsubscribe

---

<div class="post-metadata">

**Author:** ![DogByteMarketing](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dogbytemarketing/32/11625_2.png) [@DogByteMarketing](https://forum.mautic.org/u/DogByteMarketing)\
**Post date:** [January 1, 2025, 4:44am UTC](https://forum.mautic.org/t/one-click-unsubscribe-header-full-do-not-contact-is-excessive/34560/7 "2025-01-01T04:44:43Z")

</div>

This may go against Google’s [Email Sender Guidelines](https://support.google.com/a/answer/81126).

 ![sending-guidelines](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6952a61fcfd4e96587134f309f5ca3c6279c5a38.jpeg)
