nodejs で SMTP サーバーを構築しようとしていて、ユーザー認証でスタックしています。user: foo と pass: bar でユーザーを認証する関数を作成するにはどうすればよいですか?
var simplesmtp = require("simplesmtp"),
fs = require("fs");
var options = {
requireAuthentication: true,
debug: true
};
var smtp = simplesmtp.createServer(options);
smtp.listen(9845);
smtp.on("authorizeUser", function (connection, username, password, callback) {
callback(new Error("Auth fail!"), true);
});
smtp.on("startData", function(connection){
console.log("Message from:", connection.from);
console.log("Message to:", connection.to);
connection.saveStream = fs.createWriteStream("message.txt");
});
smtp.on("data", function(connection, chunk){
connection.saveStream.write(chunk);
});
smtp.on("dataReady", function(connection, callback){
connection.saveStream.end();
console.log("Incoming message saved to message.txt");
callback(null, "ABC1"); // ABC1 is the queue id to be advertised to the client
//callback(new Error("Rejected as spam!")); // reported back to the client
});