From 469c384e0930dd2b7c0f01c03cca95f86f05277d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 21 Mar 2023 00:06:39 -0700 Subject: ses mail --- routes/email.js | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'routes/email.js') diff --git a/routes/email.js b/routes/email.js index 1b551864..1f7ce4a0 100644 --- a/routes/email.js +++ b/routes/email.js @@ -1,7 +1,8 @@ import { bail } from "$lib/utils"; import got from "got"; import config from "$config"; -import sendgrid from "@sendgrid/mail"; +import { SESClient, CloneReceiptRuleSetCommand } from "@aws-sdk/client-ses"; +import { SendEmailCommand } from "@aws-sdk/client-ses"; export default { async send({ body }, res) { @@ -11,26 +12,44 @@ export default { .post("https://www.google.com/recaptcha/api/siteverify", { form: { secret, - response, - }, + response + } }) .json(); if (success) { delete body.token; - 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); + let client = new SESClient({ region: "us-east-2" }); + await client.send( + new SendEmailCommand({ + Destination: { + CcAddresses: [], + ToAddresses: ["support@coinos.io"] + }, + Message: { + Body: { + Html: { + Charset: "UTF-8", + Data: JSON.stringify(body) + }, + Text: { + Charset: "UTF-8", + Data: JSON.stringify(body) + } + }, + Subject: { + Charset: "UTF-8", + Data: body.subject || "Email Signup" + } + }, + Source: "support@coinos.io" + }) + ); + res.send({ ok: true }); } else { bail(res, "failed captcha"); } - }, + } }; -- cgit v1.2.3