Created
June 15, 2018 16:46
-
-
Save JosephScript/bda441e96485867cddd902129ac37f59 to your computer and use it in GitHub Desktop.
Mailgun Zeit Micro Nodejs
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
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