diff options
| author | Adam Soltys <[email protected]> | 2024-08-26 21:17:43 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-08-26 21:17:43 -0700 |
| commit | fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7 (patch) | |
| tree | aa8f34e1692bd2d638a2c996eeadb58671d07aea /lib/mail.js | |
| parent | 00e43ddc0bf3d6dd719fc9295d156567fa2fecfb (diff) | |
| download | coinos-server-fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7.tar.gz coinos-server-fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7.zip | |
typescript
Diffstat (limited to 'lib/mail.js')
| -rw-r--r-- | lib/mail.js | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/lib/mail.js b/lib/mail.js deleted file mode 100644 index 16b3dbbf..00000000 --- a/lib/mail.js +++ /dev/null @@ -1,44 +0,0 @@ -import { l, err, warn } from "$lib/logging"; -import config from "$config"; -import { SESClient } from "@aws-sdk/client-ses"; -import { SendEmailCommand } from "@aws-sdk/client-ses"; -import handlebars from "handlebars"; -import fs from "fs"; -import path from "path"; - -let Charset = "UTF-8"; - -export let templates = { - verifyEmail: "templates/payments/verify.html", - paymentReceived: "templates/payments/received.html", - passwordReset: "templates/payments/reset.html", -}; - -export let mail = async (user, subject, template, params) => { - try { - l("sending mail", user.username, subject); - if (!user.email) return; - - let source = fs.readFileSync(template, "utf8"); - let html = handlebars.compile(source)(params); - - let client = new SESClient({ region: "us-east-2" }); - - await client.send( - new SendEmailCommand({ - Destination: { - ToAddresses: [user.email], - }, - Message: { - Body: { - Html: { Charset, Data: html }, - }, - Subject: { Charset, Data: subject }, - }, - Source: `"Coinos " <${config.support}>`, - }), - ); - } catch (e) { - err("failed to send email", e.message); - } -}; |
