Created
February 25, 2021 14:20
-
-
Save mechmillan/14ed34aed1217ff3adea7af13ec0b263 to your computer and use it in GitHub Desktop.
Email Blog Post - Sample Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 }); | |
// Add any additional .eml files in the same directory containing this script | |
// and update the second parameter on the .join function here. | |
const source = fs.readFileSync(path.join(__dirname, 'Your_locally_saved_message_here.eml')); | |
try { | |
const scan = await scanner.scan(source); | |
// For a list of properties available for inspection, see: | |
// https://www.npmjs.com/package/spamscanner#scannerscansource | |
console.log('Scan results, scan.mail:', scan.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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment