Move from sendgrid to nodemailer for emails

This commit is contained in:
Rotimi Best
2023-10-07 02:35:25 +01:00
parent 2040257916
commit 7a772dc3f0
9 changed files with 345 additions and 167 deletions
+23 -12
View File
@@ -1,9 +1,10 @@
import { render } from 'svelte-email';
import { json } from '@sveltejs/kit';
import WelcomeTemplate from './template.svelte';
import { getSendgrid, SENDGRID_FROM } from '$lib/utils/services/sendgrid';
import { getSupabase } from '$lib/utils/functions/supabase';
import { sendEmail } from '$lib/utils/services/notification/send';
const sendgrid = getSendgrid();
const supabase = getSupabase();
@@ -28,19 +29,29 @@ export async function POST({ request }) {
return json({ success: false, message: 'Unauthenticated user' }, { status: 401 });
}
const options = {
from: SENDGRID_FROM,
await sendEmail({
to,
subject: 'Thank you so so so much for choosing ClassroomIO!',
html: render({
template: WelcomeTemplate,
props: {
name
}
})
};
sendgrid.send(options);
content: `
<p>Dear ${name},</p>
<p>My name is Best the CEO of ClassroomIO and I will personally like to welcome to the vibrant community of ClassroomIO!</p>
<p>
We're thrilled to have you join us in shaping the future of education. Your decision to embark on
this journey with us is deeply appreciated, and we're genuinely excited about the possibilities
that lie ahead.
</p>
<p>
Once again, welcome to the ClassroomIO family. We're here to help, to listen, and to celebrate
your successes. Get ready to unlock a world of possibilities in education!
</p>
<p>
If you have any question or face any issues just send me an email [email protected] 😃
</p>
<div>
<a href="https://app.classroomio.com">Go to Dashboard</a>
</div>
`
});
return json({
success: true,