From e4702b4d13e4d966d735c2ba4657e10d7c436a57 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 28 Feb 2023 12:08:13 -0800 Subject: switch to sendgrid --- routes/email.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'routes') diff --git a/routes/email.js b/routes/email.js index 529307e6..05f682af 100644 --- a/routes/email.js +++ b/routes/email.js @@ -1,24 +1,18 @@ import config from "$config"; +import sendgrid from "@sendgrid/mail"; export default { async send({ body }, res) { - try { - let postmark = await import("postmark"); - let client = new postmark.ServerClient(config.postmark); - - await client.sendEmail({ - From: "support@coinos.io", - To: "support@coinos.io", - Subject: body.subject || "Email Signup", - HtmlBody: JSON.stringify(body), - TextBody: JSON.stringify(body), - MessageStream: "outbound" - }); + sendgrid.setApiKey(config.sendgrid); + const msg = { + to: "support@coinos.io", + from: "support@coinos.io", + subject: body.subject || "Email Signup", + text: JSON.stringify(body), + html: JSON.stringify(body) + }; + await sendgrid.send(msg); res.send({ ok: true }); - } catch (e) { - console.log("problem sending email", e); - res.code(500).send(e.message); - } } }; -- cgit v1.2.3