Skip to content

This Google Appscript scans your gmail inbox for spam keywords, unsubscribes from those emails if an unsubscribe link is available and then deletes the mail. It then sends you a summary of what was deleted and unsubscribed from with a link to take you to each email so you can recover them if necessary.

Notifications You must be signed in to change notification settings

RNBBarrett/Gmail-Spam-Cleaner---Sir-Spamabot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Gmail-Spam-Cleaner---Sir-Spamabot🧹🤖

Spam Cleaner Bot

This Google Apps Script scans your Gmail inbox for a pre-define list of spam keywords and then deletes the mail it finds. It then sends you a summary of what was deleted together with an unsubscribe link if you want to unsubscribe from future spam.

Features:

  • Keyword-based spam detection: Detects spam emails based on a customizable list of keywords.
  • Unsubscribe link: Captures an Unsubscribe link for the user to use later.
  • Detailed Summary: Sends you a summary of deleted emails, with links to find and restore them from trash if you want to.

🚀 How to Set Up:

1. Open Google Apps Script:

  • Go to Google Apps Script.
  • Click the New Project button to create a new Apps Script project.

2. Paste the Code:

  • Copy the script from this repository.
  • In the Google Apps Script editor, paste the script into the main code editor window.
  • Find and edit the gmail emails in the script - there are two places.

3. Save the Script:

  • Once the script is pasted, click the File menu and then Save.
  • Give the project a name like Gmail Spam Cleaner.

4. Grant Permissions:

  • Before running the script, Google Apps Script will request permissions to access your Gmail.
  • Click Run -> cleanUpSpam() for the first time, and the script will prompt you to grant the necessary permissions.
  • Follow the prompts and approve the required permissions to allow the script to manage your Gmail inbox.

5. Set Up Triggers to Automate the Script:

To make the script run automatically at a set interval (daily, weekly, etc.), you'll need to set up a trigger:

  1. Open the Triggers Menu:

    • In the Apps Script editor, click the clock icon in the left-hand toolbar (or go to Triggers -> Add Trigger from the top menu).
  2. Create a Trigger:

    • Choose which function to run: Select cleanUpSpam.
    • Select event source: Choose Time-driven.
    • Select type of time-based trigger: Select Day timer for daily cleanup, or Week timer for weekly cleanup.
    • Set time of day: Choose a specific time for the script to run (e.g., every morning).
  3. Save the Trigger:

    • Click Save, and the trigger will be scheduled. The script will now run automatically at the selected intervals to clean your inbox.

🧰 Customization Options:

1. spamKeywords (Array):

The list of keywords used to detect spam. The script searches for these keywords in both the subject line and body of the email. You can easily expand this list to add new keywords based on your preferences.

var spamKeywords = [
  'unsubscribe', 'promotion', // Add more keywords as needed...
];

2. allowList (Array):

This list contains trusted email addresses or domains that you want to exclude from being marked as spam. These emails will not be affected by the script even if they match a keyword.

var allowList = [
  '@myschool.edu',
  '[email protected]',
  '[email protected]'
];

Add your trusted contacts or domains here. You can expand this array with any other email addresses or domains you want to exclude from spam filtering.

3. Your Email Address:

Make sure to set your email address in the recipient variable to receive the summary report. The script sends a summary of deleted and unsubscribed emails to this address.

var recipient = "[email protected]";

Update this to your email address to ensure the summary of deleted and unsubscribed emails is delivered to you.

📧 Summary Email:

The script sends a detailed summary of:

Deleted Emails: Includes the email address, subject, and a link to recover each deleted email from the trash as well as an unsubscribe link.

🛡️ Permissions Required:

Gmail Access: The script requires access to your Gmail account in order to read, filter, and delete emails, as well as to unsubscribe from certain senders.

👷 Contributing:

If you have any suggestions for improvements or new features, feel free to open an issue or submit a pull request. Contributions are always welcome!

About

This Google Appscript scans your gmail inbox for spam keywords, unsubscribes from those emails if an unsubscribe link is available and then deletes the mail. It then sends you a summary of what was deleted and unsubscribed from with a link to take you to each email so you can recover them if necessary.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published