From 29c862c70dcf59950030769a3c57bd63d23e9936 Mon Sep 17 00:00:00 2001 From: NIYOMUGABO BERNARD <85235653+niyobern@users.noreply.github.com> Date: Fri, 3 May 2024 16:23:20 +0000 Subject: [PATCH] feat: Update email sending function to use MailerSend API --- src/emails/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/emails/index.ts b/src/emails/index.ts index fbeb9416..de6ed64e 100644 --- a/src/emails/index.ts +++ b/src/emails/index.ts @@ -31,11 +31,11 @@ async function sendEmail(emailType: EmailType, recipient: string, data: Data) { // Send the Email - const domain2 = process.env.MAILERSEND_DOMAIN - const key2 = process.env.MAILERSEND_TOKEN - const body2 = { + const domain = process.env.MAILERSEND_DOMAIN + const key = process.env.MAILERSEND_TOKEN + const body = { 'from': { - 'email': `info@${domain2}`, + 'email': `info@${domain}`, }, 'to': [ { @@ -46,10 +46,10 @@ async function sendEmail(emailType: EmailType, recipient: string, data: Data) { 'html': html } const mailersend = 'https://api.mailersend.com/v1/email' - const response = await axios.post(mailersend, body2, { + const response = await axios.post(mailersend, body, { headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${key2}` + 'Authorization': `Bearer ${key}` } }); return response