shellphone.app/mailers/welcome-mailer.ts
2021-10-31 16:16:29 +01:00

34 lines
663 B
TypeScript

import previewEmail from "preview-email";
import { sendEmail } from "integrations/aws-ses";
import { render } from "./renderer";
type ResetPasswordMailer = {
to: string;
userName: string;
};
export async function welcomeMailer({ to, userName }: ResetPasswordMailer) {
const html = await render("welcome", { name: userName });
const msg = {
from: "mokhtar@shellphone.app",
to,
subject: "Welcome to Shellphone",
html,
};
return {
async send() {
if (process.env.NODE_ENV === "production") {
return sendEmail({
recipients: [msg.to],
subject: msg.subject,
html: msg.html,
});
}
return previewEmail(msg);
},
};
}