Skip to content

Instantly share code, notes, and snippets.

@JosephScript
Created June 15, 2018 16:46
Show Gist options
  • Save JosephScript/bda441e96485867cddd902129ac37f59 to your computer and use it in GitHub Desktop.
Save JosephScript/bda441e96485867cddd902129ac37f59 to your computer and use it in GitHub Desktop.
Mailgun Zeit Micro Nodejs
const {buffer, text, json} = require('micro')
const Mailgun = require('mailgun-js')
const mailgun = new Mailgun({apiKey: 'api_key', domain: 'domain'})
module.exports = async (req, res) => {
const js = await json(req)
const data = {
from: js.from,
to: '[email protected]',
subject: 'Hello from Mailgun',
html: 'Hello, This is not a plain-text email, I wanted to test some spicy Mailgun sauce in NodeJS!'
}
mailgun.messages().send(data, function (err, body) {
if (err) {
console.log("got an error: ", err)
return err
}
else {
return 200
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment