@tayar/email
Version:
A simple email package for Tayar architecture
37 lines • 1.28 kB
JavaScript
// src/sendResetPasswordEmail.ts
import { getConfig } from "@tayar/config";
import { Resend } from "resend";
async function sendResetPasswordEmail({
to,
subject,
resetURL
}) {
try {
const config = getConfig();
if (!config || !config.resendToken) {
throw new Error("Configuration not found");
}
const resend = new Resend(config.resendToken);
const { data, error } = await resend.emails.send({
from: "contact@sikka.io",
to,
subject,
text: "From sikka.io",
html: `<p>You are receiving this because you (or someone else) have requested the reset of the password for your account.</p>
<p>Please click on the following link, or paste this into your browser to complete the process:</p>
<p><a href="${resetURL}">Reset Password</a></p>
<p>If you did not request this, please ignore this email and your password will remain unchanged.</p>`
});
if (error) {
console.error("Error sending email: \u274C\u274C\u274C ", error);
}
if (data)
console.log("Email sent: \u{1F601}\u{1F601}\u{1F601}", data);
} catch (error) {
console.error("Error sending email:\u274C\u274C\u274C", error);
}
}
export {
sendResetPasswordEmail
};
//# sourceMappingURL=index.mjs.map