d7cc711b93
- 가입→검색→장바구니→승인→메일→정산까지 단계별 카드 - 장바구니 미리보기 + 자동발송 메일 미리보기 추가 - 우측 상단 회원가입/로그인 버튼은 기존 유지 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
69 lines
2.4 KiB
JavaScript
69 lines
2.4 KiB
JavaScript
// SMTP 단독 테스트 — DB 의존 없이 메일 발송 확인
|
|
// 사용법: node scripts/test-smtp.mjs <받는사람이메일>
|
|
import nodemailer from "nodemailer";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const envPath = path.join(__dirname, "..", ".env.development");
|
|
if (fs.existsSync(envPath)) {
|
|
for (const line of fs.readFileSync(envPath, "utf-8").split(/\r?\n/)) {
|
|
const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
if (m) process.env[m[1]] ??= m[2].replace(/^["']|["']$/g, "");
|
|
}
|
|
}
|
|
|
|
const to = process.argv[2] || "chpark@wace.me";
|
|
const host = process.env.SMTP_HOST;
|
|
const port = Number(process.env.SMTP_PORT || 465);
|
|
const user = process.env.SMTP_USER;
|
|
const pass = process.env.SMTP_PASS;
|
|
const from = process.env.SMTP_FROM || user;
|
|
|
|
console.log("[smtp]", { host, port, user, from, to });
|
|
|
|
if (!host || !user || !pass) {
|
|
console.error("SMTP 환경변수가 누락되었습니다.");
|
|
process.exit(1);
|
|
}
|
|
|
|
const transporter = nodemailer.createTransport({
|
|
host, port, secure: port === 465,
|
|
auth: { user, pass },
|
|
tls: { rejectUnauthorized: false },
|
|
connectionTimeout: 15000,
|
|
socketTimeout: 20000,
|
|
});
|
|
|
|
try {
|
|
console.log("[smtp] verify connection...");
|
|
await transporter.verify();
|
|
console.log("[smtp] ✔ verify OK");
|
|
|
|
console.log("[smtp] sending test mail...");
|
|
const info = await transporter.sendMail({
|
|
from,
|
|
to,
|
|
subject: "[모모유통] SMTP 연결 테스트",
|
|
html: `
|
|
<div style="font-family:'Apple SD Gothic Neo','Malgun Gothic',sans-serif;padding:24px;color:#0f172a">
|
|
<h2 style="color:#0f766e">모모유통 메일 서버 테스트</h2>
|
|
<p>이 메일이 도착했다면 SMTP 발송이 정상 작동하는 것입니다.</p>
|
|
<ul>
|
|
<li>발송 호스트: <b>${host}:${port}</b></li>
|
|
<li>발송 계정: <b>${user}</b></li>
|
|
<li>발송 시각: ${new Date().toLocaleString("ko-KR")}</li>
|
|
</ul>
|
|
<p style="color:#64748b;font-size:12px;margin-top:24px">실제 발주 승인 시에는 이 메일에 거래명세표 엑셀(.xlsx) 파일이 첨부됩니다.</p>
|
|
</div>`,
|
|
text: "모모유통 SMTP 테스트 메일입니다.",
|
|
});
|
|
console.log("[smtp] ✔ sent:", info.messageId);
|
|
console.log("[smtp] response:", info.response);
|
|
} catch (err) {
|
|
console.error("[smtp] ✖ FAILED");
|
|
console.error(err);
|
|
process.exit(2);
|
|
}
|