diff options
| author | Adam Soltys <[email protected]> | 2023-02-28 12:08:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-28 12:08:18 -0800 |
| commit | e4702b4d13e4d966d735c2ba4657e10d7c436a57 (patch) | |
| tree | a38b7f1f3e0089159eec87131cb9d575e59297df /routes | |
| parent | 80fe35caae77ab6551c35f340a18007e2bfb9750 (diff) | |
| download | coinos-server-e4702b4d13e4d966d735c2ba4657e10d7c436a57.tar.gz coinos-server-e4702b4d13e4d966d735c2ba4657e10d7c436a57.zip | |
switch to sendgrid
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/email.js | 26 |
1 files changed, 10 insertions, 16 deletions
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: "[email protected]", - To: "[email protected]", - Subject: body.subject || "Email Signup", - HtmlBody: JSON.stringify(body), - TextBody: JSON.stringify(body), - MessageStream: "outbound" - }); + sendgrid.setApiKey(config.sendgrid); + const msg = { + to: "[email protected]", + from: "[email protected]", + 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); - } } }; |
