NodeJS nodemailer - IIS SMTP 虚拟服务器

NodeJS nodemailer - IIS SMTP Virtual Server

我正在尝试使用 nodemailer (https://www.npmjs.com/package/nodemailer) 通过我们拥有的本地 windows 服务器和 SMTP 虚拟服务器发送电子邮件。

SMTP 虚拟服务器工作正常,我们已经在 Classic ASP 中使用 Jmail,将服务器名称传递给它,然后电子邮件就被发送了。

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);

我得到的错误是:

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

如果我更新 options 对象以包含 auth,如下所示:

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

我收到这个错误:

Invalid login: 504 5.7.4 Unrecognized authentication type

如何使用我们的 IIS SMTP 虚拟服务器 nodemailer 发送电子邮件..?

我仍然不知道为什么上面的方法不起作用,指向 nodemailer 我们的 SMTP 虚拟服务器。但是我已经解决了它。

我们的 SMTP 虚拟服务器设置为使用我们的 Office 365 帐户,因此我更新了我的 nodemailer 代码以直接转到 Office 365,而不是通过我们的本地服务器。

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

这有效。