You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fipamo/brain/api/content/mailer.js

42 lines
1.0 KiB
JavaScript

var express = require('express');
var router = express.Router();
var api_key = 'key-4ef13da32fb39b9d9f0370c9efba7f06';
var domain = 'communique.playvicio.us';
var mailgun = require('mailgun-js')({
apiKey: api_key,
domain: domain
});
router.post('/', function (req, res, next) {
// create reusable transporter object using the default SMTP transport
// setup e-mail data with unicode symbols
var mailOptions = {
from: req.body.email, // sender address
to: 'ro@playvicio.us', // list of receivers
subject: 'Availability Inquiry', // Subject line
text: "Message from: " + req.body.client + " <" + req.body.email + "> - " + req.body.description + " - " + req.body.type
};
mailgun.messages().send(mailOptions, function (error, body) {
if (error) {
res.json({
error: error
});
}
console.log(body);
res.json({
message: "message sent"
});
});
});
module.exports = router;