diff --git a/integrations/aws-ses.ts b/integrations/aws-ses.ts index 79857c7..7aef542 100644 --- a/integrations/aws-ses.ts +++ b/integrations/aws-ses.ts @@ -11,7 +11,7 @@ const credentials = new Credentials({ const ses = new SES({ region: serverRuntimeConfig.awsSes.awsRegion, credentials }); type SendEmailParams = { - text: string; + text?: string; html: string; subject: string; recipients: string[]; @@ -22,10 +22,12 @@ export async function sendEmail({ text, html, subject, recipients }: SendEmailPa Destination: { ToAddresses: recipients }, Message: { Body: { - Text: { - Charset: "UTF-8", - Data: text, - }, + Text: text + ? { + Charset: "UTF-8", + Data: text, + } + : undefined, Html: { Charset: "UTF-8", Data: html, diff --git a/mailers/forgot-password-mailer.ts b/mailers/forgot-password-mailer.ts index 74279da..cc503bc 100644 --- a/mailers/forgot-password-mailer.ts +++ b/mailers/forgot-password-mailer.ts @@ -1,7 +1,7 @@ import previewEmail from "preview-email"; import { sendEmail } from "integrations/aws-ses"; -import { render, plaintext } from "./renderer"; +import { render } from "./renderer"; type ResetPasswordMailer = { to: string; @@ -13,16 +13,12 @@ export async function forgotPasswordMailer({ to, token, userName }: ResetPasswor // In production, set APP_ORIGIN to your production server origin const origin = process.env.APP_ORIGIN || process.env.BLITZ_DEV_SERVER_ORIGIN; const resetUrl = `${origin}/reset-password?token=${token}`; - const [html, text] = await Promise.all([ - render("forgot-password", { action_url: resetUrl, name: userName }), - plaintext("forgot-password", { action_url: resetUrl, name: userName }), - ]); + const html = await render("forgot-password", { action_url: resetUrl, name: userName }); const msg = { from: "mokhtar@shellphone.app", to, subject: "Reset your password", html, - text, }; return { @@ -32,7 +28,6 @@ export async function forgotPasswordMailer({ to, token, userName }: ResetPasswor recipients: [msg.to], subject: msg.subject, html: msg.html, - text: msg.text, }); } else { // Preview email in the browser diff --git a/mailers/renderer.ts b/mailers/renderer.ts index ba03310..0a944ea 100644 --- a/mailers/renderer.ts +++ b/mailers/renderer.ts @@ -10,13 +10,6 @@ export async function render(templateName: string, locals: Record = {}) { - const { template, options } = getMaizzleParams(templateName, locals); - const { plaintext } = await Maizzle.plaintext(template, options); - - return plaintext; -} - function getMaizzleParams(templateName: string, locals: Record) { const template = fs .readFileSync(path.resolve(process.cwd(), "./mailers/templates", `${templateName}.html`))