summaryrefslogtreecommitdiff
path: root/lib/mail/sendEmail.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mail/sendEmail.ts')
-rw-r--r--lib/mail/sendEmail.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/mail/sendEmail.ts b/lib/mail/sendEmail.ts
index b4d2707a..3b358ea8 100644
--- a/lib/mail/sendEmail.ts
+++ b/lib/mail/sendEmail.ts
@@ -8,6 +8,7 @@ interface SendEmailOptions {
template: string; // 템플릿 파일명(확장자 제외)
context: Record<string, any>; // 템플릿에 주입할 데이터
cc?: string | string[]; // cc 필드 추가 - 단일 이메일 또는 이메일 배열
+ from?: string; // from 필드 추가 - 옵셔널
attachments?: {
// NodeMailer "Attachment" 타입
filename?: string
@@ -23,6 +24,7 @@ export async function sendEmail({
template,
context,
cc, // cc 매개변수 추가
+ from, // from 매개변수 추가
attachments = []
}: SendEmailOptions) {
try {
@@ -47,9 +49,12 @@ export async function sendEmail({
// 템플릿 컴파일 및 HTML 생성
const html = loadTemplate(template, templateData);
+ // from 값 설정 - 매개변수가 있으면 사용, 없으면 기본값 사용
+ const fromAddress = from || `"${process.env.Email_From_Name}" <${process.env.Email_From_Address}>`;
+
// 이메일 발송
const result = await transporter.sendMail({
- from: `"${process.env.Email_From_Name}" <${process.env.Email_From_Address}>`,
+ from: fromAddress,
to,
cc, // cc 필드 추가
subject,
@@ -59,7 +64,7 @@ export async function sendEmail({
console.log(`이메일 발송 성공: ${to}`, result.messageId);
return result;
-
+
} catch (error) {
console.error(`이메일 발송 실패: ${to}`, error);
throw error;