import nodemailer from 'nodemailer'; import handlebars from 'handlebars'; import fs from 'fs'; import path from 'path'; import i18next from 'i18next'; // Nodemailer Transporter 생성 const transporter = nodemailer.createTransport({ host: process.env.Email_Host, port: 465, secure: true, auth: { user: process.env.Email_User_Name, pass: process.env.Email_Password, }, }); // Handlebars 템플릿 로더 함수 function loadTemplate(templateName: string, data: Record) { const templatePath = path.join(process.cwd(), 'lib', 'mail', 'templates', `${templateName}.hbs`); const source = fs.readFileSync(templatePath, 'utf8'); const template = handlebars.compile(source); return template(data); } handlebars.registerHelper('t', function(key: string, options: any) { // options.hash에는 Handlebars에서 넘긴 named parameter들(location=location 등)이 들어있음 return i18next.t(key, options.hash || {}); }); export { transporter, loadTemplate };