This is the third iteration of my app to allow all users to opt out of email sent through Salesforce.
Last week I posted an add-on to the existing app to improve it. Here I have a totally new version with all the bells and whistles.
Could you please install it and test it for me? It should take about 10-15 minutes. After collecting enough feedback, I’ll submit this version to the AppExchange for security review.
Instructions
Install this unmanaged package in a sandbox, dev org or scratch org that doesn’t have a previous version of this app.
Make sure My Domain is set up. 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: select the Visualforce page Unsubscribe.
- A default web address does not need to be specified.
- Save.
- Click on the button Public Access Settings at the top.
- Give the Site Guest user access to the Visualforce page UnsubscribeFinish:
- Click on Visualforce Page Access then Edit.
- Add the Visualforce Page UnsubscribeFinish to the Enabled Visualforce Pages list.
- Save.
- Go back to the main page for Sites.
- In the top section of the page under “What is a Site?” look for the box that says “Your Salesforce site domain is” and copy the value there for the next step for when you modify the Custom Metadata Type.

Modify the Custom Metadata Type
- In Setup, search for and click on Custom Metadata Types.
- Click Manage Records to the left of Unsubscribe Link.
- Click the record Unsubscribe.
- In Site Domain, paste in the site domain you created earlier.
- In Our Organization, type in the name of your organization or company. This will appear in the unsubscribe link and the flow screens.
- 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 your own email so you can troubleshoot while you’re setting this up. These are additional emails beyond the emails the system sends with an error.
Field and Object Level Security
- Give the appropriate users access to:
- Unsubscribe Link fields for Contact and Lead. Give this field visibility to anyone sending commercial/promotional email out of Salesforce.
- Unsubscribe__c object and its fields for anyone tracking the frequency of unsubscribes.
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 Email, Created Date, Status
- Create a contact with your email address.
- Send a test email.
- Send an email to that contact and insert the Unsubcribe Link merge field into an email. 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.”
Success!
Or not…? Let me know! DM @forcethesales on Twitter. Were the instructions clear? What could be improved? Thank you very much!
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 Link, UnsubscribeContactsv1, UnsubscribeLeadsv1.
- Open the record for your Site.
- Change the “Active Site Homepage” to any other Visualforce page in your system.
- Deactivate the site. Sorry but you are unable to delete Force.com Sites.
- From Setup, search for “Installed Packages” and uninstall.
Hello Great App!! I am having an issue with giving the Link to my sales team to add to there Lightning Templates. It gives a merge field error below. Do you have an idea how i can get around this. Thank You
This template doesn’t support SML merge fields. Use the merge field picker to replace merge fields starting with “{!”.: HTML Value
Thank you so much for testing it! I’m not able to reproduce this. How are they sending out the email? List Views or to one contact at a time? Can you send me the template or some screen shots? jrymph@salesforce.com
Thanks for helping me out. Love the new tool.