This commit is contained in:
2026-01-25 13:42:28 +01:00
parent 4dbf566f0c
commit c074a5d935
13 changed files with 383 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import nodemailer from "nodemailer";
import { render } from "@react-email/components";
import { ReactElement } from "react";
import { getServerAppServices } from "@/lib/services/create-services.server";
const transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST,
@@ -30,12 +31,14 @@ export async function sendEmail({ to, subject, template }: SendEmailOptions) {
html,
};
const logger = getServerAppServices().logger.child({ component: 'mailer' });
try {
const info = await transporter.sendMail(mailOptions);
console.log("Email sent: %s", info.messageId);
logger.info("Email sent successfully", { messageId: info.messageId, subject, recipients });
return { success: true, messageId: info.messageId };
} catch (error) {
console.error("Error sending email:", error);
logger.error("Error sending email", { error, subject, recipients });
return { success: false, error };
}
}