📢 Add a feedback form (#590)

This commit is contained in:
Luke Vella 2023-03-21 16:31:12 +00:00 committed by GitHub
parent ef1fd25a7c
commit e8fd472ef6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 177 additions and 3 deletions

View file

@ -2,6 +2,7 @@ import * as aws from "@aws-sdk/client-ses";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import { render } from "@react-email/render";
import { createTransport, Transporter } from "nodemailer";
import type Mail from "nodemailer/lib/mailer";
import React from "react";
import * as templates from "./templates";
@ -81,11 +82,10 @@ export const sendEmail = async <T extends TemplateName>(
return;
}
const transport = getTransport();
const Template = templates[templateName] as TemplateComponent<T>;
try {
await transport.sendMail({
await sendRawEmail({
from: {
name: "Rallly",
address: process.env.SUPPORT_EMAIL,
@ -101,3 +101,13 @@ export const sendEmail = async <T extends TemplateName>(
options.onError?.();
}
};
export const sendRawEmail = async (options: Mail.Options) => {
const transport = getTransport();
try {
await transport.sendMail(options);
return;
} catch (e) {
console.error("Error sending email");
}
};