<?xml version= "1.0" encoding= "utf-8" standalone= "yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Tools on Spinning Code</title>
    <link>https://spinningcode.org/tags/tools/</link>
    <description>Recent content in Tools on Spinning Code</description> <generator>Hugo -- 0.157.0</generator>
    <language>en-US</language> <lastBuildDate>Mon, 01 Sep 2025 00:00:00 +0000</lastBuildDate> <atom:link href= "https://spinningcode.org/tags/tools/feed.xml" rel= "self" type= "application/rss+xml" /> <item>
      <title>Salesforce Email Invalidator Tool</title>
      <link>https://spinningcode.org/2025/salesforce-email-invalidator-tool/</link>
      <pubDate>
        Mon, 01 Sep 2025 00:00:00 +0000
      </pubDate> <guid isPermaLink="false">https://spinningcode.org/2025/salesforce-email-invalidator-tool/</guid>  <description>A Salesforce tool to invalidate email addresses in an org to prevent accidental messages.</description> <content:encoded><![CDATA[<p>One of the nightmares of most Salesforce Administrators is the day that their full copy sandbox sends fake email messages to real people. To help us all sleep better, I created a tool to <a href="https://github.com/acrosman/SalesforceInvalidateEmail">make it easy to invalidate all the email addresses</a> in all the email fields in your sandbox.</p>






<figure class="figure">
  
  <a href="/images/posts/sf-email-invalidator/InvalidatorScreenShot.png" target="_blank" rel="noopener noreferrer">
    
    

    











<noscript>
  <img class="rcf-image" src="/images/posts/sf-email-invalidator/InvalidatorScreenShot.png" alt="This tool has it&#39;s own app called &#39;Invalidate Email Addresses&#39; show in the picture" loading="lazy" />
</noscript>

<img class="rcf-image lazyload show-if-js"
     data-srcset="/images/posts/sf-email-invalidator/InvalidatorScreenShot_hu_a91cdb7bc64761ee.png 680w, /images/posts/sf-email-invalidator/InvalidatorScreenShot_hu_303ad7ee38729dc9.png 850w, /images/posts/sf-email-invalidator/InvalidatorScreenShot_hu_ea242e6eb916dfe5.png 1020w, /images/posts/sf-email-invalidator/InvalidatorScreenShot_hu_c9eccb12f90e2603.png 1360w, /images/posts/sf-email-invalidator/InvalidatorScreenShot_hu_96f48e56ecf69c66.png 2040w, /images/posts/sf-email-invalidator/InvalidatorScreenShot.png 2994w"
     data-src="/images/posts/sf-email-invalidator/InvalidatorScreenShot.png"
     src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAA5CAIAAABxmbQhAAAPt0lEQVR4nOw8a3McuXHdQAMzs&#43;RJOuris&#43;&#43;ccpWTD6nK//8ZqUo5&#43;eYPcfniR51z1okiuTsDoDsF9AwWO7uiKIniI5WmjkfOYnqAfr&#43;G9ONV&#43;N1ft//2p&#43;vLMb3e0L980//rt8O3584TInxxEBFmjjGmlJhZCgAAIpoC&#43;vPnPwUAjDFEZIy5F4QppRBCjBERrbUAEEIAACLSzVtr9bl6xv1hE//tp8v/&#43;uNfxin&#43;4puXNCW5CXw18Zsts8RvNukmZEqAIDwABw5PVfeqZFIe3Au9lBb3CCISC&#43;j2Qgjv3r0DgGEYbAHvfSthAMDMKSUBk5jJWiYJMZE1MDj8erAI8LK3Xw&#43;2JzR3P3JmVTne3U6Yt1v/NRcVlPQigg18GoHWD71vaOWj3SoeQlXo/R7QnA3dxdcvEnPvHZ1785uX3gpvA7/s7bdf&#43;VedQeGU&#43;JYD1AdKSjJNMo2cEqicHWqO6H96EdEQma5D56GoraKpRG9NkD70HiX3fjlqjPHeq8FBRCJSQ1RNUNVdESGi5izofTf0HQsQGQwx3Yzh7c0YYuwd9c4YYeHZImdc5QsKHbNhKkiJqOs6awyEEK/ehbdvw26XYszPyLeU9XpTMezl9GCJ/ObMv3xlz87AOVT2LCbiJK0R7s0SYtkZrCXkU0B04zL/gIACe9GZH9dwenW0Yi9YxZLiFDAGn0aTooE4BQnTNI5TCEGEszPJXxYRON8iegjf&#43;fPz8853mGIYw2437q5vQgjMrPyvO&#43;ACKibO&#43;41xMgRyARn2dJgP9GUBAR7Yq90CC0eE/vzDj8xxmqaUki2ECyFMxb8L86xLRZvU0GNZY629GrbeeyOSdrtwM4axBDIimEnPVQ6kqEDhB9g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5tFWQOJzizmvHJ/Pu24jlPY7nbzeL7o&#43;x77wVXId61nuY5nh3RCS/&#43;iTvvSHDY15T2ryuJqXrQ&#43;Qs51y&#43;sw0NRLynuHz18DQuSr7VRemTzWAA6x0DXV0QeuY4VSO&#43;/zrAnMA1cVhcjyFrUs83pVrGVu/jcr5/cykVdKZlMa42RNOnx7VFKSq&#43;0U4vMdSclA2zH&#43;9PP23fW0aqvrH3VajXIukzlSF0EdPNWhLFhGr9q/TYFw/Do0HjxrH800eGZuIYSTOQeLTCFtx&#43;fNAQqBL1MwGG/7mx9P08yq5eSnEJF9OhALSJIEJ&#43;eunza0ivNs4X8DAAD///jvL/tyNM8MAAAAAElFTkSuQmCC"
     data-sizes="auto"
     width="2994" alt="This tool has it&#39;s own app called &#39;Invalidate Email Addresses&#39; show in the picture"
     loading="lazy" />



  </a></figure>

<p>When I <a href="/tags/data-migrations/">migrate data</a> I often add <code>.invalid</code> to all the email fields in the org. More than once this saved my team from accidentally sending a large number of messages. Having a tool to do this easily in a sandbox has been on my todo list for a long time.</p>
<h2 id="why-invalidate-salesforce-emails">Why Invalidate Salesforce Emails</h2>
<p>Salesforce automatically adds <code>.invalid</code> onto the end of email addresses of Users to avoid accidental sends from sandboxes. This is great when you have an experience cloud portal setup. Because Salesforce&rsquo;s core platform is not an email marketing platform Contacts, Leads, and other objects with email fields are left unaltered. But lots of organizations <em>use</em> the core platform to drive a marketing platform. The use add-ons and data syncs, or they use the org to send transactional email directly from Salesforce. When the org is the tool that initiates the send, there is a risk that a sandbox with real data can send invalid messages. I&rsquo;ve seen sandboxes send <em>a lot</em> of messages during testing of new features or when an automation was left switched on that should have been disabled.</p>
<p>Most Salesforce consultants I know have stories about times when an org sent unwanted email messages to a client&rsquo;s contacts. Those events are embarrassing at best. At worst they can expose you to financial or legal liability.</p>
<p>Often these events happen when someone makes a simple error with a full copy sandbox, or an org with migrated data under review. The story outline generally is that while testing an automation, or a scheduled process, a team member sets Salesforce to send messages. They forget to disable email again, or they don&rsquo;t think about a scheduled automation set to run at 2 AM. Minutes or hours later that sandbox triggers dozens, hundreds, even thousands of emails.</p>
<h3 id="cant-i-just-disable-email-in-salesforce">Can&rsquo;t I Just Disable Email in Salesforce?</h3>
<p>You can, and should, <a href="https://help.salesforce.com/s/articleView?id=platform.data_sandbox_email_deliverability.htm&amp;type=5">disable email deliverability</a> in most sandboxes most of the time. But in my experience that&rsquo;s not sufficient all of the time.</p>
<p>That setting is good, but less than perfect. Sometimes you need deliverability switched on to test features or deploy changes. Sometimes you use a 3rd party email system that ignores that setting. By actually breaking every email address nothing can slip through.</p>
<h2 id="how-my-salesforce-email-invalidator-works">How My Salesforce Email Invalidator Works</h2>
<p>This tool uses a series of custom metadata records to determine which objects and fields have emails you want to invalidate (it comes with a sample record to invalidate the Email field on Contact). When the batch process runs – either from the provided app or post sandbox copy – it will add <code>.invalid</code> onto the end of any existing data in the field. It does not check to see if the value is actually an email, but it does ensure <code>.invalid</code> is only added once and ignores blank values.</p>
<p>The tool provides <a href="https://help.salesforce.com/s/articleView?id=platform.apps_overview_lightning.htm&amp;type=5">an app</a> that gives you a place to see and update the exiting field list, a button to initiate the process, and allows you to replace the <code>.invalid</code> text with a different string. You can also have it automatically run after a sandbox completes its process by entering <code>InvalidateEmailSandboxPostCopy</code> as the Apex class to run when creating the sandbox. I created the tool to be metadata driven so that the setup carries down from the production org into new sandboxes.</p>
<h2 id="security">Security</h2>
<p>Please be careful when installing and using my email invalidator. It is designed to break data – that&rsquo;s the whole point. I have not put it through Salesforce security review, and I don&rsquo;t plan to bother. I&rsquo;m not even sure they would approve a tool designed to break data. It does have a permission set that should be giving out on a <em>very</em> restricted basis to highly trusted users – ideally don&rsquo;t assign it to anyone in production including yourself.</p>
<p>I am releasing the invalidator tool <a href="https://github.com/acrosman/SalesforceInvalidateEmail">as an open source project</a>. You are free to review the code and validate that it does what I&rsquo;ve described. I will do my best to answer any questions you post to the <a href="https://github.com/acrosman/SalesforceInvalidateEmail/issues">issue queue</a>.</p>
<h2 id="installation">Installation</h2>
<p>The current setup is just a collection of loose metadata in a repo. Until I get around to packaging it you&rsquo;ll want someone who is comfortable with git and sf cli to support installation. You should clone <a href="https://github.com/acrosman/SalesforceInvalidateEmail">the repo</a> to your local machine and push all the metadata into your org with sf cli&rsquo;s <code>sf project deploy start</code> command.</p>
<p>Of course please install in a sandbox first and test it out there before putting a copy in production. To make it easy to use over time it will need to be in production.</p>
<h2 id="feedback-and-suggestions">Feedback and Suggestions</h2>
<p>I am open to, and interested in, feedback. Currently the tool is a very early alpha quality version. It works, but hasn&rsquo;t been tested in a lot of use cases. In the <a href="https://github.com/acrosman/SalesforceInvalidateEmail/issues">project issue queue</a> you can offer feedback, report bugs, or make suggestions. I&rsquo;d also enjoy getting code contributions as well.</p>
]]></content:encoded> </item> </channel>
</rss>
