Nodemailer抛出错误连接ECONNREFUSED

时间:2018-06-29 00:35:49

标签: javascript node.js nodemailer

我试图弄清楚如何使nodemailer与Siteground托管一起工作,但是每当尝试从本地主机发送联系表单时,我都会不断收到ECONNREFUSED消息。对我可能做错的任何想法?

let transporter = nodemailer.createTransport({
            host: 'mail.something.com',
            port: 143,
            secure: false, // true for 465, false for other ports
            auth: {
                user: 'useremail', // generated ethereal user
                pass: 'userpass' // generated ethereal password
            },
            tls:{
              rejectUnauthorized: false
            }

        });

        // setup email data with unicode symbols
        let mailOptions = {
            from: '"Nodemailer Contact" <email>', // sender address
            to: 'me', // list of receivers
            subject: 'Node Contact Request ✔', // Subject line
            text: 'Hello world?', // plain text body
            html: output // html body
        };

        // send mail with defined transport object
        transporter.sendMail(mailOptions, (error, info) => {
            if (error) {
                return console.log(error);
            }
            console.log('Message sent: %s', info.messageId);
            console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));

            res.render('/contact-us', {msg: 'Email has been sent'});

        });

0 个答案:

没有答案