Nodemailer: Unable to send email from custom smtp server

Created on 11 Aug 2014  路  17Comments  路  Source: nodemailer/nodemailer

This is the conf that works for me in thunderbird client:
Authentication method:NTLM
Connection Security: STARTTLS
so I've try to set this params in my configuration below but still no luck.

var transporter = nodemailer.createTransport(smtpTransport('SMTP',{
            host: 'mail.mysmtpserver.com',
            port: 587,
            auth: {
                user: '[email protected]',
                pass: 'mypasswd'
            },            
            authMethod:'NTLM',
            secure:false,
            ignoreTLS:false,
            debug:true
        })
    );

I'm getting :{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }

I'm able to get a response by doing this from a console(Im using linux)
openssl s_client -starttls smtp -connect mail.mysmtpserver.com:587 -crlf

Any ideas on how to fix this...

Most helpful comment

Node.js can not verify the certificate of your SMTP server. You can skip certificate verification by using rejectUnauthorized: false option

var transporter = nodemailer.createTransport(smtpTransport('SMTP',{
            host: 'mail.mysmtpserver.com',
            port: 587,
            auth: {
                user: '[email protected]',
                pass: 'mypasswd'
            },            
            authMethod:'NTLM',
            secure:false,
            tls: {rejectUnauthorized: false},
            debug:true
        })
    );

All 17 comments

If you are using the latest Nodemailer, then drop the 'smtp' string argument

Hello Andris Thanks for the fast response, if I remove the 'SMTP' string
I'm get :
[Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE]

Im using version 1.1.1 according to package.json

Node.js can not verify the certificate of your SMTP server. You can skip certificate verification by using rejectUnauthorized: false option

var transporter = nodemailer.createTransport(smtpTransport('SMTP',{
            host: 'mail.mysmtpserver.com',
            port: 587,
            auth: {
                user: '[email protected]',
                pass: 'mypasswd'
            },            
            authMethod:'NTLM',
            secure:false,
            tls: {rejectUnauthorized: false},
            debug:true
        })
    );

where getting there ....
I'm using it like this:

var transporter = nodemailer.createTransport(smtpTransport({
            host: 'mail.mysmtpserver.com',
            port: 587,
            auth: {
                user: '[email protected]',
                pass: 'mypasswd'
            },            
            authMethod:'NTLM',
            secure:false,
            tls: {rejectUnauthorized: false},
            debug:true
        })
    );

and I get
[Error: Unknown authentication method "NTLM"] code: 'EAUTH'

I've been able to send mails with this conf:

var transporter = nodemailer.createTransport(smtpTransport({
            host: 'mail.mysmtpserver.com',
            port: 587,
            auth: {
                user: '[email protected]',
                pass: 'mypasswd'
            },
            tls: {rejectUnauthorized: false},
            debug:true
        })
    );

Now I'm not an expert so my concern is in terms of security or reliability ... is this the right aproach? will the system always deliver mail with thisconfiguration?, because of the options that I've ommited for the smtp server

Another Question: Since I'm using nodemailer for Application error delivery

Do I always need to close the transporter?
how will nodemailer will behave on a uncauthException, will nodemailer still be able to deliverMail?

exports.sendMail=function(){  
    transporter.sendMail(mailOptions, function(error, info){
        if(error){
            console.log(error);
        }else{
            console.log('Message sent: ' + info.response);
        }
        transporter.close();//is this the right place to close it?
    });
};

Thanks for your support

You seem to follow an outdated guide, see this for an actual example. There is no close method anymore, unless you are using the pooled connections plugin.

NTLM is supported?

NTLM is not supported

And there are plans to support it?

Last update on this was Oct 2014 and the issue is closed, and I am sure I know the answer, but is NTLM support in the future a realistic expectation?

I have nothing against NTLM _per se_. I just have no clue how to test it as It seems to be Microsoft specific and I know nothing about Windows based systems.

Got this error

{ Error: connect ECONNREFUSED 127.0.0.1:25
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ECONNECTION',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 25,
command: 'CONN' }

@andris9 after creating transport, can we do verify transport transport.verify before sending email?

I am trying creating the transport as
service: 'mail.hkd-consulting.com',
auth: {
user: 'no-reply@**.com',
pass: '***'
},
tls: {rejectUnauthorized: false},
logger: false, // log to console
debug: true

it gives me no error give me success message but i received no email.

unable to send email to user1: [email protected]
{ RecipientError: Can't send mail - all recipients were rejected
at SMTPClient._actionRCPT (/ATOM_PROD_PORTAL/New_Prod_Portal/node_modules/simplesmtp/lib/client.js:1054:27)
at SMTPClient._onData (/ATOM_PROD_PORTAL/New_Prod_Portal/node_modules/simplesmtp/lib/client.js:354:29)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:601:20)
name: 'RecipientError',
data: '550 relay not permitted',
stage: 'rcpt' }
Executing (default): SELECT 1+1 AS result
GET 304 - 1.854 ms /@lgi-atom/atom-base/latest/assets/atom/css/lgi-atom-base.css
events.js:183
throw er; // Unhandled 'error' event
^

Error: 140200002385792:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:../deps/openssl/openssl/ssl/s3_pkt.c:365:

I'm getting this error while sending mail from node mailer on centos 7

and please helpm with fix this
C:\Users\USER\Angineers\nilejobs-BE\node_modules\nodemailer\lib\mailerindex.js:45
this.transporter.mailer = this;
^

TypeError: Cannot set property 'mailer' of undefined

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Meenakshi14 picture Meenakshi14  路  13Comments

AshishkrGoyal picture AshishkrGoyal  路  17Comments

miranagha picture miranagha  路  8Comments

murvinlai picture murvinlai  路  14Comments

abhatia-lix picture abhatia-lix  路  7Comments