Tag Archives: nodejs email

[Source | Nodejs] 이메일 발송

Nodejs에서 이메일 발송코드를 정리한다.


작성일 : 2021-04-22
nodeJs Ver : v16.13.1


1> nodemailer 설치

npm install nodemailer

2> 코드작성

let transporter = nodemailer.createTransport({
   host: "OPENDOCS_SMTP_HOST",   // SMTP Host
   port: 465,
   secure: true,                 // true for 465, false for other ports
   auth: {
      user: "OPENDOCS_USERID",   // User ID
      pass: "OPENDOCS_USERPW"    // User Password
   }
});

let info = await transporter.sendMail({
   from: '"OPENDOCS" <corp@opendocs.co.kr>',     // Sender Address
   to: "opendocs@naver.com, opendocs@kakao.com", // Receiver List
   subject: "Hello ✔", // Subject line
   text: "Hello world?", // plain text body
   html: "<b>Hello world?</b>" // html body
});