# 이메일 보내기
- sendgrid 가입해야함
- twilio의 explore products에서 email 누르면 sendgrid로 이동함
- 포기함 그냥 nodemailer 사용하는게 좋을듯
- - 네이버 이메일 > 환경설정 > pop3/imap tjfwjd
- - 탭두개다 사용함 체크하고 저장
- - npm install --save nodemailer @types/nodemailer
email.js 파일만들기
import nodemailer from "nodemailer";
const smtpTransport = nodemailer.createTransport({
service: "Naver",
host: "smtp.naver.com", //앱에서확인가능
port: 587, //앱에서확인가능
auth: {
user: process.env.MAIL_ID, // 본인네이버메일
pass: process.env.MAIL_PASSWORD, // 본인비번(2단계인증에서 생성한 앱용 비번)
},
tls: {
rejectUnauthorized: false,
},
});
export default smtpTransport;
if (email) {
const mailOptions = {
from: process.env.MAIL_ID,
to: email,
subject: "Nomad Carrot Authentication Email",
text: `Authentication Code : ${payload}`,
};
const result = await smtpTransport.sendMail(
mailOptions,
(error, responses) => {
if (error) {
console.log(error);
return null;
} else {
console.log(responses);
return null;
}
}
);
smtpTransport.close();
console.log(result);
}
'프로그래밍 > NextJS' 카테고리의 다른 글
next Radix 설치 및 사용 (1) | 2024.01.22 |
---|---|
nextjs prisma 넥스트 프리즈마 세팅 (0) | 2024.01.22 |
nextjs api폴더 리팩토링 (0) | 2024.01.06 |
nextjs 페이지이동 Link,useRouter (0) | 2024.01.05 |
nextjs에서 prsima, planetScale 연결 (1) | 2024.01.04 |