// var _ = require('lodash');
// var fetch = require('node-fetch');
// var querystring = require('querystring');
var mailgun = require('mailgun-js')({
apiKey: 'key-6eaad285924f73be6032401e131d2c0b',
domain: 'amplelabs.cc'
});
var email = {
from: 'Shopify App<
[email protected]>',
to: '
[email protected]',
subject: 'RB Test',
// text: 'Text Email Test!',
html: '<h1>HTML Email Test!!!</h1>'
};
mailgun.messages().send(email, function(error, body) {
console.log(body);
});
// console.log('querystring', querystring);
// var body = {
// form_type: 'contact',
// utf8: '✓',
// contact: {
// name: 'John',
// email: '
[email protected]',
// phone: '888',
// body: 'test from runkit'
// }
// };
// console.log('body', body);
// var bodyFlat = _.merge(body, body.contact);
// delete bodyFlat.contact;
// console.log('bodyFlat', bodyFlat);
// console.log('email', body.email);
// var bodyArray = _.map(body, function(val, key) {
// return key + ': ' + val;
// });
// bodyArray.unshift(
// 'Form submission from: ' + '"contact"' + ' form'
// );
// var messageBody = bodyArray.join('\n');
// // POST with form parameters (x-www-form-urlencoded)
// var params = {
// from: '
[email protected]',
// to: '
[email protected]',
// subject: bodyArray[0],
// text: messageBody,
// 'o:tag': 'shopify-app-bypassOrigFormAction'
// };
// var opts = {
// method: 'POST',
// headers: {
// 'content-type': 'application/x-www-form-urlencoded',
// authorization: 'Basic <AUTH HERE>'
// },
// body: querystring.stringify(params)
// };
// console.log('opts', opts);
// // Call the Mailgun API to send the email
// fetch(
// 'https://api.mailgun.net/v3/<DOMAIN HERE>/messages',
// opts
// )
// .then(function(request) {
// return request.json();
// })
// .then(function(response) {
// // Redirect to show thank you message
// console.log('res', response);
// });