import { Lettr } from 'lettr';
const lettr = new Lettr(process.env.LETTR_API_KEY);
export const handler = async (event) => {
try {
const { to, subject, html } = JSON.parse(event.body);
await lettr.emails.send({
from: 'you@example.com',
to: [to],
subject,
html
});
return {
statusCode: 200,
body: JSON.stringify({ message: 'Email sent successfully' })
};
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({ error: error.message })
};
}
};