I am using nodemailer in my backend to send mails over smtps from gmail (yes, smtp, not oauth2 cuz the latter is super tough to figure out, and does not work either way, and less secure apps is turned on) but for some reason, it would never verify login for me and would output this:
Error: connect ETIMEDOUT <someip that I censored>:587
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1146:16) {
errno: -4039,
code: 'ESOCKET',
syscall: 'connect',
address: '<someip>',
port: 587,
command: 'CONN'
}
Since the password had @ and # in it, and as far as I know, smtps logs in by a URL kind of thing, so I changed the password and removed both of these. Then, when I tried verifying login, and emailing, it worked once! Then I stopped the node process, changed some code BUT NOTHING OF THE STATEMENT OF CREATING TRANSPORTER and when I tried re-logging back in, it started to give back the same error. I tried in both, options object method, and the string method. The code that worked once for me was
const transporter = nodemailer.createTransport(`smtps://${process.env.EMAIL_ADDRESS}@gmail.com:${process.env.EMAIL_PWD}@smtp.gmail.com/?pool=true`);
transporter.verify((error, success)=>{
if (error) return log.error(error);
log.success(`Connected to smtp.gmail.com with ${process.env.EMAIL_ADDRESS}@gmail.com`);
});
NOTE: ${process.env.EMAIL_ADDRESS} is just the xyz part in xyz@gmail.com
But afterwards, even this did not work for me. I even rollbacked the whole code A to Z of what it was when it DID work, but that too would output the same error for some reason, and I can not figure out the solution. I did not change a single thing in verifying login but for some reason it would never work! Please help!