aboutsummaryrefslogtreecommitdiffstats
path: root/routes/email.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-21 00:06:39 -0700
committerAdam Soltys <[email protected]>2023-03-21 00:06:39 -0700
commit469c384e0930dd2b7c0f01c03cca95f86f05277d (patch)
tree17b24286259596987e74913d72e4733ec58c4f1d /routes/email.js
parentc99665a0a0ac79176726169a49d5f9ebaae325bc (diff)
downloadcoinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.tar.gz
coinos-server-469c384e0930dd2b7c0f01c03cca95f86f05277d.zip
ses mail
Diffstat (limited to 'routes/email.js')
-rw-r--r--routes/email.js45
1 files changed, 32 insertions, 13 deletions
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 = {
- 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: ["[email protected]"]
+ },
+ 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: "[email protected]"
+ })
+ );
+
res.send({ ok: true });
} else {
bail(res, "failed captcha");
}
- },
+ }
};