Ban Emails
I get plenty of annoying spam emails from so-called legitimate business. My favorite way to get rid of them is this little Powershell script that I invoke from Launchbar after I copied the email address I want to ban!
param(
[string]$email
)
$domain = $email.Split("@")[1]
Connect-ExchangeOnline -UserPrincipalName my@email.com
New-InboxRule -Name "From $domain" -DeleteMessage $True -FromAddressContainsWords $domain
For this to work, you need to replace my@email.com
with your actual email and it only support Exchange/Microsoft365 tenants.
From Launchbar, I launch it through a script (there’s probably a better way, I’m sure)
#!/bin/sh
/usr/local/bin/pwsh -File ~/.dotfiles/bin/ban_email.ps1 -email $(pbpaste)