{"size": 749, "ext": "js", "max_stars_repo_path": "functions/send-quote-mail.js", "max_stars_repo_name": "jacastrorug/TexgoApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "functions/send-quote-mail.js", "max_issues_repo_name": "jacastrorug/TexgoApp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "functions/send-quote-mail.js", "max_forks_repo_name": "jacastrorug/TexgoApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.0294117647, "max_line_length": 93, "alphanum_fraction": 0.6568758344}
const mailgun = require("mailgun-js");

const mg = mailgun({
  apiKey: process.env.APIKEY,
  domain: process.env.DOMAIN,
});

const mailData = {
  from:
    "Texgo Transport Quote <postmaster@sandbox5d61013d7fcd40d1a684457ccdd0a29b.mailgun.org>",
  to: "ghunt@texgotrans.com",
  subject: "New quote message from Texgo Transport",
  template: "quote_message",
};

exports.handler = async function (request) {
  const body = request.body;
  mailData["h:X-Mailgun-Variables"] = body;

  try {
    const response = await mg.messages().send(mailData);

    return {
      statusCode: 200,
      body: JSON.stringify(response),
    };
  } catch (error) {
    return {
      statusCode: 409,
      body: JSON.stringify({ error: e.message }),
    };
  }
};
