Move from sendgrid to nodemailer for emails
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<script lang="ts">
|
||||
import EmailTemplate from '$lib/components/Email/EmailTemplate.svelte';
|
||||
import Welcome from './welcome.svelte';
|
||||
|
||||
export let name = '';
|
||||
</script>
|
||||
|
||||
<EmailTemplate
|
||||
children={Welcome}
|
||||
props={{
|
||||
name
|
||||
}}
|
||||
/>
|
||||
@@ -1,79 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Text, Section, Button, Link } from 'svelte-email';
|
||||
|
||||
export let name = '';
|
||||
|
||||
const fontFamily =
|
||||
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif';
|
||||
|
||||
const paragraph = {
|
||||
fontFamily,
|
||||
fontSize: '16px',
|
||||
lineHeight: '26px'
|
||||
};
|
||||
|
||||
const footerParagraph = {
|
||||
...paragraph,
|
||||
margin: '0px'
|
||||
};
|
||||
|
||||
const btnContainer = {
|
||||
textAlign: 'center' as const
|
||||
};
|
||||
|
||||
const button = {
|
||||
fontFamily,
|
||||
backgroundColor: '#1d4ee2',
|
||||
borderRadius: '5px',
|
||||
color: '#fff',
|
||||
fontSize: '16px',
|
||||
textDecoration: 'none',
|
||||
textAlign: 'center' as const,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
const linkStyle = {
|
||||
color: '#1d4ee2'
|
||||
};
|
||||
</script>
|
||||
|
||||
<Text style={paragraph}>Dear {name},</Text>
|
||||
<Text style={paragraph}>Welcome to the vibrant community of ClassroomIO!</Text>
|
||||
<Text style={paragraph}>
|
||||
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.
|
||||
</Text>
|
||||
<Text style={paragraph}>
|
||||
At ClassroomIO, we understand the dedication and passion that educators like you bring to the
|
||||
table. That's why we've built a platform that's not only designed to make your teaching experience
|
||||
seamless but also to empower you to create transformative learning moments for your students.
|
||||
</Text>
|
||||
<Text style={paragraph}>
|
||||
Your choice to use ClassroomIO is a testament to your commitment to innovation in education. It's
|
||||
educators like you who drive progress and inspire change, and we're here to support you every step
|
||||
of the way.
|
||||
</Text>
|
||||
<Text style={paragraph}>
|
||||
Our team is working diligently behind the scenes, shipping new features and updates daily. This
|
||||
means you can expect a platform that's constantly evolving, adapting to your needs, and staying at
|
||||
the forefront of educational technology.
|
||||
</Text>
|
||||
<Text style={paragraph}>
|
||||
We encourage you to explore ClassroomIO's range of features, from interactive quizzes and robust
|
||||
course management tools to collaborative forums and AI-integrated lesson planning. Your feedback
|
||||
is invaluable to us as we work together to refine and enhance these features to best suit your
|
||||
teaching style and objectives.
|
||||
</Text>
|
||||
<Text style={paragraph}>
|
||||
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!
|
||||
</Text>
|
||||
<Section style={btnContainer}>
|
||||
<Button pX={12} pY={12} style={button} href="https://app.classroomio.com">Go to Dashboard</Button>
|
||||
</Section>
|
||||
<Text style={footerParagraph}>Best regards</Text>
|
||||
<Text style={footerParagraph}>Rotimi Best</Text>
|
||||
<Text style={footerParagraph}
|
||||
><Link style={linkStyle} href="https://classroomio.com">ClassroomIO</Link></Text
|
||||
>
|
||||
@@ -10,9 +10,11 @@
|
||||
import { blockedSubdomain } from '$lib/utils/constants/app';
|
||||
import { welcomeModalStore } from '$lib/components/WelcomeModal/store';
|
||||
import { getOrganizations } from '$lib/utils/services/org';
|
||||
import { sendWelcomeEmail } from './utils';
|
||||
import { currentOrg } from '$lib/utils/store/org';
|
||||
import { generateSitename } from '$lib/utils/functions/org';
|
||||
import {
|
||||
triggerSendEmail,
|
||||
NOTIFICATION_NAME
|
||||
} from '$lib/utils/services/notification/notification';
|
||||
|
||||
interface OnboardingField {
|
||||
fullname?: string;
|
||||
@@ -182,7 +184,10 @@
|
||||
loading = false;
|
||||
|
||||
if (fields.fullname) {
|
||||
sendWelcomeEmail($profile.email, fields.fullname);
|
||||
triggerSendEmail(NOTIFICATION_NAME.WELCOME_TO_APP, {
|
||||
to: $profile.email,
|
||||
name: fields.fullname
|
||||
});
|
||||
}
|
||||
|
||||
console.log('data', data);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { supabase } from '$lib/utils/functions/supabase';
|
||||
|
||||
export async function sendWelcomeEmail(to: string, name: string) {
|
||||
const { data } = await supabase.auth.getSession();
|
||||
const accessToken = data.session?.access_token || '';
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/email/welcome', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: accessToken
|
||||
},
|
||||
body: JSON.stringify({
|
||||
to,
|
||||
name
|
||||
})
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(await response.text());
|
||||
}
|
||||
const result = await response.json();
|
||||
|
||||
console.log('Sent confirmation email', result);
|
||||
} catch (error) {
|
||||
console.error('Error sending confirmation email', error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user