From 2689d1aeba24dd2656d1f5c4be3e07ced5a75eeb Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 16 Mar 2023 22:14:54 +0000 Subject: [PATCH] feat: use resend for email --- nuxt.config.ts | 1 + src/server/utils/email.ts | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 99f24ced..ef7f8a3e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -10,6 +10,7 @@ export default defineNuxtConfig({ }, // emailing ideas sendgridApiKey: '', + resendApiKey: '', github: { // my GH ID id: 'MDQ6VXNlcjI4NzA2Mzcy', diff --git a/src/server/utils/email.ts b/src/server/utils/email.ts index 5eebb411..72c6b182 100644 --- a/src/server/utils/email.ts +++ b/src/server/utils/email.ts @@ -3,19 +3,16 @@ const $fetch = (url: string, body: Record) => method: 'POST', body: JSON.stringify(body), headers: { - Authorization: `Bearer ${useRuntimeConfig().sendgridApiKey}`, + Authorization: `Bearer ${useRuntimeConfig().resendApiKey}`, 'Content-Type': 'application/json', }, }) -const sender = { email: 'noreply@poetry.sh', name: 'Me' } -const recipient = { email: 'daniel@roe.dev', name: 'Daniel Roe' } - -export function sendEmail (subject: string, body: string) { - return $fetch('https://api.sendgrid.com/v3/mail/send', { - personalizations: [{ to: [recipient], subject }], - content: [{ type: 'text/plain', value: body }], - from: sender, - reply_to: sender, +export function sendEmail(subject: string, body: string) { + return $fetch('https://api.resend.com/email', { + subject, + html: body, + from: 'noreply@roe.dev', + to: 'daniel@roe.dev', }) } -- knotmirror 0.0.1