blob: 1dc72b1f667b1c03b168b801106e535cc02dc88d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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";
export let templates = {
paymentSent: "templates/payments/sent.html"
};
export let mail = async (user, subject, template, params) => {
if (!user.email) return;
let source = fs.readFileSync(path.join(__dirname, 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: config.support
})
);
};
|