feat: send welcome email upon newsletter subscription

This commit is contained in:
javayhu 2025-04-16 00:59:18 +08:00
parent dca25ac784
commit 13889cfd2a
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
'use server';
import { sendEmail } from '@/mail';
import { subscribe } from '@/newsletter';
import { getLocale } from 'next-intl/server';
import { createSafeActionClient } from 'next-safe-action';
import { z } from 'zod';
@ -28,6 +30,17 @@ export const subscribeNewsletterAction = actionClient
};
}
// Send a welcome email to the user
const locale = await getLocale();
await sendEmail({
to: email,
template: 'subscribeNewsletter',
context: {
email,
},
locale,
});
return {
success: true,
};

View File

@ -1,3 +1,4 @@
import { sendEmail } from '@/mail';
import { CheckSubscribeStatusParams, NewsletterProvider, SubscribeNewsletterParams, UnsubscribeNewsletterParams } from '@/newsletter/types';
import { Resend } from 'resend';