2021-10-30 12:31:22 +00:00
|
|
|
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") {
|
2021-10-31 15:16:29 +00:00
|
|
|
return sendEmail({
|
2021-10-30 12:31:22 +00:00
|
|
|
recipients: [msg.to],
|
|
|
|
subject: msg.subject,
|
|
|
|
html: msg.html,
|
|
|
|
});
|
|
|
|
}
|
2021-10-31 15:16:29 +00:00
|
|
|
|
|
|
|
return previewEmail(msg);
|
2021-10-30 12:31:22 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|