Stephen Last Stephen Last - 5 months ago 53
Node.js Question

NodeJS nodemailer - IIS SMTP Virtual Server

I'm trying to use

nodemailer
(https://www.npmjs.com/package/nodemailer) to send e-mail using a local windows server we have, with an SMTP Virtual Server.

The SMTP Virtual Server works fine, we already use Jmail in Classic ASP, pass it the server name, and email gets sent.

var nodemailer = require('nodemailer');
var options = {
host: 'SERVERNAME'
};
var transporter = nodemailer.createTransport(options);
var email = {
from: 'no-reply@domain.co.uk',
to: 'webmaster@domain.co.uk',
subject: 'hello',
text: 'hello world!'
};
var callback = function(err, info){
if (err) { throw err }
console.log('sent');
}
transporter.sendMail(email, callback);


The error I get back from this is:


Can't send mail - all recipients were rejected: 550 5.7.1 Unable to
relay for webmaster@domain.co.uk


If I update the
options
object to include
auth
, like this:

var options = {
host: 'SERVERNAME',
auth: {
user: '...',
pass: '...'
}
};


I get this error:


Invalid login: 504 5.7.4 Unrecognized authentication type


How can I use
nodemailer
to send e-mail using our IIS SMTP Virtual Server..?

Answer

I still don't know why the above doesn't work, pointing nodemailer to our SMTP Virtual Server. However I've worked around it.

Our SMTP Virtual Server is setup to use our Office 365 account, so I've updated my nodemailer code to go to Office 365 direct, rather than via our local server.

var options = {
    host: 'SMTP.office365.com',
    port: 25,
    secure: false,
    ignoreTLS: false,
    auth: {
        user: '...',
        pass: '...'
    },
    tls: {
        ciphers: 'SSLv3'
    }
}

This works.