shellphone.app/mailers/welcome-mailer.ts
2021-10-30 14:31:22 +02:00

35 lines
716 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") {
await sendEmail({
recipients: [msg.to],
subject: msg.subject,
html: msg.html,
});
} else {
// Preview email in the browser
return await previewEmail(msg);
}
},
};
}