2015-12-21 130 views
1

我試圖使用nodemailerhttps://www.npmjs.com/package/nodemailer)使用本地Windows服務器發送電子郵件,使用SMTP虛擬服務器。NodeJS nodemailer - IIS SMTP虛擬服務器

SMTP虛擬服務器工作正常,我們已經在傳統ASP中使用Jmail,將它傳遞給服務器名稱,併發送電子郵件。

var nodemailer = require('nodemailer'); 
var options = { 
    host: 'SERVERNAME' 
}; 
var transporter = nodemailer.createTransport(options); 
var email = { 
    from: '[email protected]', 
    to: '[email protected]', 
    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 [email protected]

如果我更新options對象包括auth,像這樣:

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

我得到這個錯誤:

Invalid login: 504 5.7.4 Unrecognized authentication type

如何使用我們的IIS SMTP虛擬服務器,使用nodemailer發送電子郵件..?

回答

0

我仍然不知道爲什麼上述不起作用,指向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' 
    } 
} 

這是有效的。