A
A
Alex Ozerov2021-05-10 08:26:26
Node.js
Alex Ozerov, 2021-05-10 08:26:26

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 );
})


PS The correct login and password come from the config

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Ozerov, 2021-05-10
@alex_vma

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 question

Ask a Question

731 491 924 answers to any question