K.. K.. - 5 months ago 24x
Node.js Question

Setting up nodemailer for SMTP

I used this setup to send a 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 get this error:

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

Seems like it ignores the host, but why?


I had the very same problem as you and I am using 1blu as well. The issue is related to the TLS library of Node. The following configuration did the job for me.


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