48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
|
|
import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses';
|
||
|
|
|
||
|
|
const ses = new SESClient({ region: process.env.AWS_REGION || 'us-east-1' });
|
||
|
|
const FROM = process.env.FROM_EMAIL || 'noreply@labwise.wahwa.com';
|
||
|
|
|
||
|
|
export async function sendEmail({
|
||
|
|
to,
|
||
|
|
subject,
|
||
|
|
html,
|
||
|
|
}: {
|
||
|
|
to: string;
|
||
|
|
subject: string;
|
||
|
|
html: string;
|
||
|
|
}) {
|
||
|
|
await ses.send(
|
||
|
|
new SendEmailCommand({
|
||
|
|
Source: FROM,
|
||
|
|
Destination: { ToAddresses: [to] },
|
||
|
|
Message: {
|
||
|
|
Subject: { Data: subject },
|
||
|
|
Body: { Html: { Data: html } },
|
||
|
|
},
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function verificationEmailHtml(url: string) {
|
||
|
|
return `
|
||
|
|
<div style="font-family:sans-serif;max-width:480px;margin:0 auto;padding:32px">
|
||
|
|
<h2 style="color:#2d5a4a;margin-bottom:8px">Verify your email</h2>
|
||
|
|
<p style="color:#555;margin-bottom:24px">Click the button below to verify your email address and activate your LabWise account.</p>
|
||
|
|
<a href="${url}" style="display:inline-block;background:#5a9584;color:white;padding:12px 28px;border-radius:6px;text-decoration:none;font-weight:600">Verify Email</a>
|
||
|
|
<p style="color:#aaa;font-size:12px;margin-top:32px">If you didn't create a LabWise account, you can ignore this email.</p>
|
||
|
|
</div>
|
||
|
|
`;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function resetPasswordEmailHtml(url: string) {
|
||
|
|
return `
|
||
|
|
<div style="font-family:sans-serif;max-width:480px;margin:0 auto;padding:32px">
|
||
|
|
<h2 style="color:#2d5a4a;margin-bottom:8px">Reset your password</h2>
|
||
|
|
<p style="color:#555;margin-bottom:24px">Click the button below to reset your LabWise password. This link expires in 1 hour.</p>
|
||
|
|
<a href="${url}" style="display:inline-block;background:#5a9584;color:white;padding:12px 28px;border-radius:6px;text-decoration:none;font-weight:600">Reset Password</a>
|
||
|
|
<p style="color:#aaa;font-size:12px;margin-top:32px">If you didn't request this, you can ignore this email.</p>
|
||
|
|
</div>
|
||
|
|
`;
|
||
|
|
}
|