Skip to content

Instantly share code, notes, and snippets.

@shammelburg
Last active March 17, 2021 14:53
Show Gist options
  • Save shammelburg/1e844b7224701e51940f361550c612b9 to your computer and use it in GitHub Desktop.
Save shammelburg/1e844b7224701e51940f361550c612b9 to your computer and use it in GitHub Desktop.
SendGrid Inbound Parse with Express
const express = require('express')
const multer = require('multer')
const app = express()
const upload = multer()
app.post('/api/parse', upload.any(), async (req, res) => {
const body = req.body
console.log("dkim: ", body.dkim);
console.log("to: ", body.to);
console.log("cc: ", body.cc);
console.log("from: ", body.from);
console.log("subject: ", body.subject);
console.log("sender_ip: ", body.sender_ip);
console.log("spam_report: ", body.spam_report);
console.log("envelope: ", body.envelope);
console.log("charsets: ", body.charsets);
console.log("SPF: ", body.SPF);
console.log("spam_score: ", body.spam_score);
if (req.files.length > 0) {
// Log file data
console.log(req.files)
} else {
console.log('No files...')
}
return res.status(200).send()
})
app.listen(3000, () => {
console.log('Webserver running on -> http://localhost:3000')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment