0

estoy intentando enviar emails a través de nodemailer y una sencilla aplicación. De alguna forma, al intentar hacer post al servidor, parece que salta un error de conexión, pero no consigo saber que pasa exactamente. Este es el código; router.post('/sendmail', function(req, res, next) { ... var transporter = nodemailer.createTransport("SMTP", { host: "smtp-mail.outlook.com", // hostname secureConnection: false, // TLS requires secureConnection to be false port: 587, // port for secure SMTP auth: { user: "[email protected]", pass: "password"

    },
    tls: {
        ciphers:'SSLv3'
    }
});



// setup e-mail data with unicode symbols
var mailOptions = {
    from: 'Username \u26AD <username@server>', // sender address

     to: '[email protected]', // list of receivers
    subject: subject,
    text: text_content, // plaintext body
    html: html_content,
};

// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
    if(error){
        return console.log(error);
    }
    console.log( info);
    res.end('Sent :)');
});

Esta es la llamada ajax a /sendMail

$.ajax({
                type: "POST",
                url: "/sendmail",
                dataType: 'json',
                data: {
                    owner: '56fab5a69835c6dc22b4603d',
                    name: $scope.reservation.name,
                    email: $scope.reservation.email,
                    notes: $scope.reservation.province+': ' + notes,
                    phone: $scope.reservation.phone,
                    origin: "albertotaboada.com configurador",
                    ip: ip
                },
                success: function (data, textStatus, xhr) {
                    $scope.form_status = "success";
                }, error: function () {
                    $scope.form_status = "success";
                }
            });

El error que salta en el moneto de hacer POST:

{ [Error: connect ECONNREFUSED 127.0.0.1:587]

code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 587, stage: 'init' }

alguien puede ayudarme por favor?? un saludo¡¡

2
  • agrega esto a tu configuración: var transport = nodemailer.createTransport("SMTP", { host: "smtp-mail.outlook.com", // hostname secureConnection: false, // TLS requires secureConnection to be false port: 587, // port for secure SMTP auth: { user: "[email protected]", pass: "password" }, tls: { ciphers:'SSLv3' } }); De manera alternativa para outlook puedes usar var transport = nodemailer.createTransport("SMTP", { service: "hotmail", auth: { user: "[email protected]", pass: "password" } }); el 12 ene. 2018 a las 23:55
  • Hola como estas intentando agregar algo xd te dejo un link con tu mismo problema resuelto quizás te pueda servir de apoyó un saludo! stackoverflow.com/questions/38024428/… el 7 dic. 2020 a las 4:41

1 respuesta 1

0

creo que te falto algo de configuración, agrega esto a tu configuración:

var transport = nodemailer.createTransport("SMTP", {
    host: "smtp-mail.outlook.com", // hostname
    secureConnection: false, // TLS requires secureConnection to be false
    port: 587, // port for secure SMTP
    auth: {
        user: "[email protected]",
        pass: "password"
    },
    tls: {
        ciphers:'SSLv3'
    }
});

Otra opcion seria usar nodemailer-wellknown :D

var transport = nodemailer.createTransport("SMTP", {
        service: "Hotmail",
        auth: {
            user: "[email protected]",
            pass: "password"
        }
    });

Saludos

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.