Skip to content

Instantly share code, notes, and snippets.

@mechmillan
Last active May 4, 2021 12:49
Show Gist options
  • Select an option

  • Save mechmillan/5dbc3f8fe8a227ed8439b7646d1dfc89 to your computer and use it in GitHub Desktop.

Select an option

Save mechmillan/5dbc3f8fe8a227ed8439b7646d1dfc89 to your computer and use it in GitHub Desktop.

Revisions

  1. mechmillan renamed this gist May 4, 2021. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // in a file called index.ts
    // in a file called index.js
    const fs = require("fs");
    const path = require("path");
    // Make sure to install spamscanner in your package.json
  2. mechmillan renamed this gist May 3, 2021. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // in a file called index.js
    // in a file called index.ts
    const fs = require("fs");
    const path = require("path");
    // Make sure to install spamscanner in your package.json
  3. mechmillan revised this gist May 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sample-spamscanner-setup.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ const scanEmail = async () => {
    const scanner = new SpamScanner({ debug: true });

    // Swap out the "Your_locally_saved_message_here.eml" file with the actual filename in the directory
    // containing this script and update the second parameter on the .join() method here.
    // containing this script
    const source = fs.readFileSync(
    path.join(__dirname, "Your_locally_saved_message_here.eml")
    );
  4. mechmillan created this gist May 3, 2021.
    31 changes: 31 additions & 0 deletions sample-spamscanner-setup.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // in a file called index.js
    const fs = require("fs");
    const path = require("path");
    // Make sure to install spamscanner in your package.json
    const SpamScanner = require("spamscanner");

    const scanEmail = async () => {
    // For a list of all options & their defaults, see:
    // https://www.npmjs.com/package/spamscanner#api
    const scanner = new SpamScanner({ debug: true });

    // Swap out the "Your_locally_saved_message_here.eml" file with the actual filename in the directory
    // containing this script and update the second parameter on the .join() method here.
    const source = fs.readFileSync(
    path.join(__dirname, "Your_locally_saved_message_here.eml")
    );

    try {
    const scanResult = await scanner.scan(source);

    // For a list of properties available for inspection, see:
    // https://www.npmjs.com/package/spamscanner#scannerscansource
    console.log("Scan results, scanResult.mail:", scanResult.mail);
    } catch (err) {
    console.error("Error in scanEmail:\n", err);
    }
    };

    scanEmail();

    // To run this script, run `node index.js` in your terminal where this script resides.