Answer the question
In order to leave comments, you need to log in
Why is nodemailer not sending mail?
Unable to send email: Error: connect ECONNREFUSED 127.0.0.1:465
require('dotenv').config()
const express = require('express')
const nodemailer = require('nodemailer')
const mailTransport = nodemailer.createTransport( {
service: 'smtp.gmail.com',
secure: false,
port: 465,
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASS
}
})
mailTransport.sendMail({
from: 'Text <[email protected]>',
to: '[email protected]',
subject: 'Text,
text: 'Text text text '
}, function(err){
if(err) console.error( 'Невозможно отправить письмо: ' + err );
})
Answer the question
In order to leave comments, you need to log in
service: 'smtp.gmail.com' - replace with host: 'smtp.gmail.com'. The example was from an old book, after the update, the host property is used
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question