aboutsummaryrefslogtreecommitdiffstats
path: root/routes/email.js
blob: 529307e6ca0c709b16484de2af093ea7653b88d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import config from "$config";

export default {
  async send({ body }, res) {
    try {
      let postmark = await import("postmark");
      let client = new postmark.ServerClient(config.postmark);

      await client.sendEmail({
        From: "[email protected]",
        To: "[email protected]",
        Subject: body.subject || "Email Signup",
        HtmlBody: JSON.stringify(body),
        TextBody: JSON.stringify(body),
        MessageStream: "outbound"
      });

      res.send({ ok: true });
    } catch (e) {
      console.log("problem sending email", e);
      res.code(500).send(e.message);
    }
  }
};