Trouble Shooting
nodemailer wrong version number 해결방법
DEV_BLOG
2022. 8. 13. 22:45
Nodemailer에서 dotenv를 설정해주는 과정에서 다음과 같은 오류가 발생하였다.
[Error: 17100:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
] {
library: 'SSL routines',
function: 'ssl3_get_record',
reason: 'wrong version number',
code: 'ESOCKET',
command: 'CONN'
}
Stackoverflow를 통해 이것이 secure 속성과 관련되었다는 것에 대한 힌트를 얻을 수 있었다.
Node.js nodemailer error - wrong version number/invalid greeting
I have a big problem with setting up the nodemailer on my node.js server. Tried everthing I found on the internet but nothing works. The only thing that was easy to setup was the gmail service. but
stackoverflow.com
본인에게 에러가 발생한 원인은 다음과 같았다.
(기존코드)
const email = {
host:process.env.{...},
port:process.env.{...},
secure:process.env.{...},
auth : {
user: process.env.{...},
pass: process.env.{...},
},
};
(변경코드)
const email = {
host:process.env.{...},
port:process.env.{...},
secure:false,
auth : {
user: process.env.{...},
pass: process.env.{...},
},
};
nodemailer에서 port 선택지를 주는데, 465 port 일때는 true이고 나머지 포트에 대해서는 false로 지정해주어야한다.
본인의 경우 .env 에 variable = false 로 주었는데 이것을 process.env.variable로 가져갈때 온전히 false로 인식을 하지 않기 때문이라고 판단하였다.
따라서 그냥 false로 해주어 문제를 해결하였다!