From 064be8e2a627bf00346eec543828b793a2859250 Mon Sep 17 00:00:00 2001 From: m5r Date: Sun, 31 Oct 2021 16:16:29 +0100 Subject: [PATCH] fix sendEmail --- integrations/aws-ses.ts | 13 +++++++------ mailers/templates/welcome.html | 6 +++--- mailers/welcome-mailer.ts | 7 +++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/integrations/aws-ses.ts b/integrations/aws-ses.ts index 7aef542..09e4931 100644 --- a/integrations/aws-ses.ts +++ b/integrations/aws-ses.ts @@ -22,12 +22,6 @@ export async function sendEmail({ text, html, subject, recipients }: SendEmailPa Destination: { ToAddresses: recipients }, Message: { Body: { - Text: text - ? { - Charset: "UTF-8", - Data: text, - } - : undefined, Html: { Charset: "UTF-8", Data: html, @@ -41,5 +35,12 @@ export async function sendEmail({ text, html, subject, recipients }: SendEmailPa Source: serverRuntimeConfig.awsSes.fromEmail, }; + if (text) { + request.Message.Body.Text = { + Charset: "UTF-8", + Data: text, + }; + } + await ses.sendEmail(request).promise(); } diff --git a/mailers/templates/welcome.html b/mailers/templates/welcome.html index eada062..02b3c88 100644 --- a/mailers/templates/welcome.html +++ b/mailers/templates/welcome.html @@ -23,7 +23,7 @@ bodyClass: bg-gray-postmark-lighter

My name is Mokhtar and I built {{ page.company.product }} after - growing tired of paying exorbitant charges for international + growing tired of paying exorbitant phone bills for international communications and getting frustrated over the lack of decent consumer-oriented cloud phone solutions.

@@ -35,8 +35,8 @@ bodyClass: bg-gray-postmark-lighter

Take care! -
{{ page.company.sender }}
Founder at {{ - page.company.product }} +
{{ page.company.sender }}
+ Founder at {{ page.company.product }}

diff --git a/mailers/welcome-mailer.ts b/mailers/welcome-mailer.ts index 0c78ed9..2bb5f3f 100644 --- a/mailers/welcome-mailer.ts +++ b/mailers/welcome-mailer.ts @@ -20,15 +20,14 @@ export async function welcomeMailer({ to, userName }: ResetPasswordMailer) { return { async send() { if (process.env.NODE_ENV === "production") { - await sendEmail({ + return sendEmail({ recipients: [msg.to], subject: msg.subject, html: msg.html, }); - } else { - // Preview email in the browser - return await previewEmail(msg); } + + return previewEmail(msg); }, }; }