I am using the built-in mailing list activation template on an EE website I am working on and would like to include an unsubscribe link at the bottom of the email.

I have tried adding the tag {unsubscribe_url} to the bottom, but it does not seem that this tag is being parsed correctly.

Is there another way of achieving this?

Here is a snippet of my code:

<td height="50" align="middle">You are receiving this message because you have signed up to receive the newsletter. To unsubscribe, please click <a href="{unsubscribe_url}" style="color:#729134;">here</a></td>
  • can you elaborate on this by showing your email template code since {unsubscribe_url} should generate a link if you are using the built in mailing module. – foamcow Nov 4 '14 at 10:54
  • Please see code added – heinkasner Nov 4 '14 at 11:22
  • Can you output the value of {unsubscribe_url} for us please? it should be an ACTion link, ie link to the index of your site with the query string ?ACT=# where # is the action number for unsubscribe in the exp_actions table. – Blatant Apr 9 '15 at 11:19

Assuming you are using the standard MailingList module and you just can't get {unsubscribe_url} to work, you can create the unsubscribe URL yourself with a little PHP snippet:


  //fetch the action ID
  $actionID = ee()->functions->fetch_action_id('Mailinglist','unsubscribe');

  //was it a valid ACT ID? If not the mailing list is probably not installed
  $unsubUrl = "";
  if ( !empty($actionID) && isnumeric($actionID) && intval($actionID) == $actionID ) {
      //create the URL
      $unsubUrl = ee()->functions->fetch_site_index(true) . '?ACT=' . $actionID;
  } else {
      //optionally handle issues here, we have no action!

  //Display the link
  if ( !empty($unsubUrl) ){ ?>

    <a href="<?php echo $unsubUrl; ?>" title="Unsubscribe">Unsubscribe</a>

  <?php }

Ammendum Of course, if you're using the standard template you can't use PHP as above...

I've copied the default template as it is supplied by the module (fresh install) and I notice a couple of little things in your snippet. Here's the default template:


To remove your email from this mailing list, click here:
{if html_email}<a href=\"{unsubscribe_url}\">{unsubscribe_url}</a>{/if}
{if plain_email}{unsubscribe_url}{/if}

I notice that the quotes are all escaped in the default template, looking at the 3rd line ({if html_email}...) you'll see all the quotes are escaped \".

Could you try the example with the escaped quotes please? Also as I mentioned can you confirm the unsubscribe action is set up correctly (i.e. is present in exp_actions)?

  • MY bad, read the question... You're using the built in template so PHP code is not allowed. I have edited my answer... – Blatant Apr 9 '15 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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