Configuring nodemailer for SMTP

I used this setup to send mail:

import NodeMailer from 'nodemailer'
import SmtpTransport from 'nodemailer-smtp-transport'

const transporter = NodeMailer.createTransport(SmtpTransport({
  host: 'smtp.1blu.de',
  port: 25,
  debug: true,
  auth: {
    user: '...',
    pass: '...'
  }
}))

transporter.sendMail(options, (error, data) => ...)

      

But I am getting this error:

Error: connect ECONNREFUSED 127.0.0.1:25
at Object.exports._errnoException (util.js:749:11)
at exports._exceptionWithHostPort (util.js:772:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1009:14)

      

It looks like it is ignoring the host, but why?

+3


source to share


1 answer


I had the same problem as yours and am using 1blu too. The problem is with the TLS Node library. The following configuration did the job for me.

Here:



var smtpTransport = nodemailer.createTransport("SMTP",{
    host: 'smtp.1blu.de',
    secureConnection: true,
    port: 465,
    auth: {
       user: '...',
       pass: '...'
    },
    tls:{
        secureProtocol: "TLSv1_method"
    }
});
console.log('SMTP Configured');

      

+4


source







All Articles