Skip to content

Instantly share code, notes, and snippets.

@krispayne
Created April 12, 2016 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krispayne/10851e7b302621cfafe1b8a2cffacfb6 to your computer and use it in GitHub Desktop.
Save krispayne/10851e7b302621cfafe1b8a2cffacfb6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# gmail message recall
# requires Got Your Back https://github.com/jay0lee/got-your-back and a service account.
CSV="user-list.csv"
MSGID="" # Enter the full message ID here from the "Show Original" in Gmail. Leave out the '<>'
GYB="" # location of Got Your Back pythyon script /Users/username/gyb/gyb.py
DOMAIN="" # google apps domain e.g. google.com
OLDIFS=$IFS
IFS=,
[ ! -f $CSV ] && { echo "${CSV} file not found"; exit 99; }
while read user
do
echo "Searching for ${MSGID} in ${user}'s mailbox"
python3 ${GYB} --service-account --search "rfc822msgid:${MSGID}" --action purge --email ${user}@${DOMAIN}
sleep 1
python3 ${GYB} --service-account --search "reference:${MSGID}" --action purge --email ${user}@${DOMAIN}
echo "Done. Sleeping 3 seconds..."
echo " "
sleep 3
done < $CSV
IFS=$OLDIFS
echo "No more users to search"
exit 0
@krispayne
Copy link
Author

user-list.csv is a list of user's on their own line.

user1
user2
user3
userN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment