29 lines
610 B
TypeScript
29 lines
610 B
TypeScript
// lib/email/sendMagicLink.ts
|
|
import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
|
|
|
|
const ses = new SESClient({
|
|
region: process.env.AWS_REGION!,
|
|
});
|
|
|
|
export async function sendMagicLinkEmail(
|
|
to: string,
|
|
link: string
|
|
) {
|
|
await ses.send(
|
|
new SendEmailCommand({
|
|
Source: process.env.SES_FROM_EMAIL!,
|
|
Destination: { ToAddresses: [to] },
|
|
Message: {
|
|
Subject: { Data: "Your login link" },
|
|
Body: {
|
|
Text: {
|
|
Data: `Click the link below to log in.
|
|
This link expires in 15 minutes.
|
|
|
|
${link}`,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
);
|
|
}
|