Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: adds cc to emails sent via the contact-notification function

Alaister Young5f3e0ce073d0
diff --git a/apps/www/supabase/functions/contact-notification/index.ts b/apps/www/supabase/functions/contact-notification/index.ts
index 4c2463496de..158e4b5bcc7 100644
--- a/apps/www/supabase/functions/contact-notification/index.ts
+++ b/apps/www/supabase/functions/contact-notification/index.ts
@@ -4,12 +4,17 @@ import { SmtpClient } from 'https://deno.land/x/[email protected]/mod.ts'
const smtp = new SmtpClient()
serve(async (req) => {
- await smtp.connect({
- hostname: Deno.env.get('SMTP_HOSTNAME')!,
- port: Number(Deno.env.get('SMTP_PORT')!),
- username: Deno.env.get('SMTP_USERNAME')!,
- password: Deno.env.get('SMTP_PASSWORD')!,
- })
+ try {
+ await smtp.connect({
+ hostname: Deno.env.get('SMTP_HOSTNAME')!,
+ port: Number(Deno.env.get('SMTP_PORT')!),
+ username: Deno.env.get('SMTP_USERNAME')!,
+ password: Deno.env.get('SMTP_PASSWORD')!,
+ })
+ } catch (error) {
+ console.log('error connecting to smtp: ', error)
+ return new Response(error.message, { status: 500 })
+ }
const body = await req.json()
@@ -39,13 +44,15 @@ serve(async (req) => {
}
try {
- await smtp.send({
+ const response = await smtp.send({
from: Deno.env.get('SMTP_FROM')!,
to,
+ cc: Deno.env.get('SMTP_CC_TO')!,
subject: `New Contact Form Submission (${form})`,
content,
})
} catch (error: any) {
+ console.log('email sending failed with error: ', error)
return new Response(error.message, { status: 500 })
}