How to Include an Unsubscribe Link, Revised

Install now from the AppExchange.

Allow Recipients to Unsubscribe From All Email Sent via Salesforce

View demo.

When the recipient clicks to unsubscribe, a flow will look for all contacts and leads who have this as their preferred email address (if you’re in Nonprofit Success Pack) or in the Email field. All contacts or leads who meet that requirement will be marked “Email Opt Out.”  The email address owner will receive one confirmation email immediately.

Please try this in your sandbox, developer org or Trailhead playground first! 

Learn why you should consider including an unsubscribe link. 


Thanks to improvements to Flow in Summer ’20 (and an additional upgrade package) this app is now much easier to install! You should know how to modify a page layout and a profile, send an email in Salesforce, and use a sandbox. You will install a package that contains Flow and Process Builder, but you don’t need to know how to use them.

Follow along with this worksheet while you’re setting up the app.

Watch the video and/or read the instructions below. This video has not been modified yet to include the new upgrade package. If you install the upgrade, you don’t need to modify the email templates as shown here.

First step: install the app from appExchange.

Second step: Set up My Domain. Instructions here from Trailhead.

Create a Site

  • (Setup -> User Interface -> Sites and Domains -> Sites)
  • Create a new Site.
  • If you don’t have a Site domain, you’ll need to set one up. You may want to use the same domain as your “My” domain.
  • Label: Make the label the name of your organization or whomever the confirmation email should appear from. I will put “Ugly Dog Adoption Agency” and the unsubscribe confirmation email will appear from “Ugly Dog Adoption Agency Site Guest User.”
  • Site Name: Unsubscribe (so internally you know what this is about).
  • Site Contact: Defaults to your user.
  • Click Active.
  • Active Site Home Page: find the Visualforce page Unsubscribe.
  • A default web address does not need to be specified.
  • Save.
  • Copy and save the Site URL for use in a later step.

Modify the Flow for Summer ’20

  • Open Unsubscribe Part 1 Flow. 
    • Modify the variable OrganizationName (not a Summer ’20 update).
      • To do so, click on Manager in the left column under “Toolbox.”
      • Click on OrganizationName.
      • Replace “our organization” under default value with the name of your organization. This will appear in the confirmation email and on the flow screens.
  • Click Save As.
  • Click Show Advanced.
  • Under “How to Run the Flow,” select System Context without Sharing–Access All Data. Click Save. Click Activate. (This step is required after Summer ’20).

Get Alerts For Flow Errors

  • In Setup, search for and click on Custom Metadata Types.
  • Click Manage Records to the left of Error Email Recipients.
  • Click New.
  • Type in “Unsubscribe” for the label and for the field “Error Email Recipients Name”, although the values here don’t actually matter.
  • In “Comma Separated Email List” make a list of email addresses you’d like to receive custom error messages when the Flows have errors. I’d put yourself so you can troubleshoot while you’re setting this up.
  • Earlier versions of this app already have a record and it has my email address. Please change it!

Install Additional Package – It’s Quick

Install the new (October 2020) upgrade to the Unsubscribe Link! Use this instead of the email templates that come with the original App.

Modify or Remove the Confirmation Email

To remove the confirmation email all together, follow the instructions here.

To modify the content:

  • To change only the phrase “our organization,” see the instructions above under “Modify the Flow for Summer ’20.”
  • To change the rest of the email body:
    • Open Unsubscribe Part 1 Flow.
    • Click on Manager in the left column under “Toolbox.”
    • Click on PlainTextEmailBody under “Formulas.”
    • Modify the formula.
  • Click Save As.
  • Click Show Advanced.
  • Under “How to Run the Flow,” select System Context without Sharing–Access All Data. Click Save. Click Activate.

Test It Out

  • In your sandbox, make sure Email Deliverability is turned on.
    • Go to setup. Search for “Deliverability.”
    • Set the access level to “All email.”
    • Be very careful if you are using a sandbox with real data – do you have any automated processes that are now going to start firing off emails like crazy? Remember to turn off email deliverability when you’re done testing.
  • Optional: Edit your Contact and Lead page layouts.
    • Add the Email Opt Out field.
    • Add the Unsubscribe related list. You may want to add other fields here like Unsubscribe EmailCreated DateStatus
  • Create a contact with your email address.
  • TEST IT!
    • Send an email to that contact (using the template you created) to test it. Make sure the contact has “Email Opt Out” unchecked.
    • When you click the link it should look like this.

The next page should look like this.

  • Look for that confirmation email.
  • Open the contact record and confirm the following:
    • Email opt out is now checked
  • There is a new related Unsubscribe record and Status = “Unsubscribed.”

How to Uninstall the Package

If you have any Unsubscribe__c records from using this package, you’ll lose them by uninstalling.

  • Deactivate the Flows: Unsubscribe Part 1, Unsubscribe Contacts, Unsubscribe Leads.
  • Deactivate the Process Builder: UnsubscribePB.
  • Open the record for your Site.
  • From Setup, search for “Installed Packages” and uninstall.


  1. Thanks so much for this, I have tried testing it but I am receiving this error: Error element Create_Unsubscribe_Record (FlowRecordCreate).
    This error occurred when the flow tried to create records: INVALID_FIELD_FOR_INSERT_UPDATE: Unsubscribe__c: bad field names on insert/update call: Contact__c, Status__c, Unsubscribe_Email__c, Lead__c. Do you know what could be the issue here? Thanks again.


    1. Have you given permission to your site guest user to access all of those fields on the Unsubscribe object?


  2. Not sure what I’m missing here, but I can’t find this:

    (Setup -> User Interface -> Sites and Domains -> Sites)


    1. Edit – nevermind, sites are unavailable in professional edition. Therefore, this app is unavailable in professional edition


      1. Bummer! Sorry about that! Check on AppExchange for edition requirements when installing.

    1. thanks for trying the app. I need more information. you could email me at jrymph @ salesforce .com


  3. Hey,
    I have completed the process and can send the test mail and unsubscribe.

    Next, how do I automatically add the “unsubscribe” button to the existing or newly created email campaigns?


  4. Hey awesome people,

    Our client complained about the “Your flow is finished” end page. And we attempted to modify your Visualforce Markup of VF page “Unsubscribe” to redirect into client domain (see line 6 below):

    Any ideas where did we exactly mess up on the code to enable the redirect to homepage instead of seeing “Your flow is finished”?
    Or completely get rid of the “Your flow is finished”? page.


    1. Hello! Sorry that I didn’t respond to your earlier comment. Looks like you figured out how to update the templates? don’t see your code here. I will hopefully have time to look into your issue before I go on leave! Thanks for your patience.


  5. Hello – and thanks for this app!
    I installed and configured, I tested and works perfectly.
    I have one question though – I can’t seem to be able to make it work with Lightning Email Templates. I’ve tried to insert the Unsubscribe link in the templates – but I get an error: “This email template has two kinds of merge fields. Remove or replace merge fields in the format {!object.field}, such as {!Contact.FirstName}. Use the merge field picker to insert merge fields with the format {{{Object.field}}}.: HTML Value”

    Any thought on this?
    All our current templates are Lightning so it would be great if we could make unsubscribe work with these.


    1. Thanks for trying the app! First dumb question, did you find the instructions above on working in Lightning templates?


      1. Hey – sorry I missed your reply (I thought i’ll get notified and did not check back). I managed to make it work at that point and ever since.
        Now – it’s not working anymore… I did not change anything on it, we’ve sent plenty of emails since.
        With the current emails sent if you click on unsubscribe you get the message “Something went wrong. Sorry about that. We were not able to unsubscribe you at this time, but we have been alerted about the problem.”

        And I get notified by email.

        Not even sure where to begin debugging 🙁

      2. Hi! I’m on maternity leave right now and don’t have the capacity to help right now. I have gotten an increase in issues lately so I’m guessing that something may have happened with Summer 20 related to Secure Guest User security. My apologies!

    2. Hi! I’m so sorry for the delay. I’ve revised the instructions now for Summer ’20, if you’d like to try again.


  6. Hi Jessie,

    Instructions were pretty straight forward. i believe i configured everything properly. However, when i do a test, and click the unsubscribe link i get a page that simply says “Your Flow Finished”.

    What am i missing?


    1. Hello! A very delayed follow up, but the instructions have been modified now for Summer ’20, if you’re interested in trying it again.


  7. I have installed everything and getting an error with my test contacts selects to unsubscribe. It is creating the Unsubscribe Object but not updating the email opt out field. I get the following error. Something went wrong. Sorry about that. We were not able to unsubscribe you at this time, but we have been alerted about the problem. It runs in debug and I an not getting an email with any error in it. Can anyone help.?


    1. Hi! I’m on maternity leave right now and don’t have the capacity to help right now. I have gotten an increase in issues lately so I’m guessing that something may have happened with Summer 20 related to Secure Guest User security. My apologies!


      1. Hey Jim! So sorry for the delay. I’ve revised the instructions now for Summer 20 if you’re interested in trying it again.

  8. I had the same problem as Jim above – two specific email addresses kicked back errors, it shows nothing in the FoundId field in the error message. I think I’ve partially fixed it by adding lead and account sharing rules as OP specified in the video under Sharing Rules in Spring 20. Those two email addresses still kick back errors but everyone else is able to unsubscribe. I’m not sure why the two email addresses are problematic, they don’t have special characters.


    1. That’s an interesting problem, Kelly! So sorry I wasn’t able to help earlier. I’ve updated the instructions now for Summer 20. No more sharing rules! Hopefully that will help!


  9. Hi Jessie,
    I stumble Upon this package when helping a NGO with a similar requirement. They want to confirm subscribe instead of unsubscribe. I was able to modify the flow in the package. This is a great tool and also very instructions too. Thanks for creating this!!

    One thing want to see if you have any pointer. What is the best to make the initial email sent manually and the confirmation email have the same From Name and Email address?


      1. Hi Jessie,
        No worries. I figured it out, by editing the Site Guest User name.
        That’s the email from name appear from the confirmation email.

        On another note, in case others are run into this also.
        When using Lightning Email Template, the email goes out, but when clicking the link it didn’t work for me initially because it was not encoded by default.
        So instead of three curly bracket. I tried two instead. Then it work.

        At the end, I was able to modify it to help a NGO send out subscription sign up email automatically (using workflow + a workaround) upon a new contact.

        Thanks again Jessie for creating this App

  10. HI Jessie,
    Thanks for the hard work! I have just installed from app-exchange and followed instructions. I am on lightning.
    A couple things have come up:
    Where can I change the text for the confirmation email?


Leave a Reply