I use simplesmpt for smpt server. I want create my error answers. For example when user try auth I want write "User doesnot exists" or "Account banned". I look into server.js and find code which send to client this answers. But how can I send my answer?
this.client.send("535 5.7.8 Error: authentication failed: no mechanism available");
This is part of code from server.js. How to change this answers from my script and generate my own answers?
If I understand correctly, you want a custom error message to be sent when a user fails authentication. There shouldn't be a need to edit the SimpleSMTP source code.
When creating a simple SMTP server instance, set requireAuthentication to true and add an event handler function for authorizeUser.
Example code mockup:
var options = {
...
requireAuthentication: true
};
var smtp = simplesmtp.createServer();
smtp.listen(25);
smtp.on("authorizeUser", function (connection, username, password, callback) {
// your custom asynchronous validation function
userIsNotAuthorized(function(isValidated){
if(isValidated)
{
return callback(new Error("535 5.7.8 Error: authentication failed: no mechanism available", false);
}
callback(null, true);
});
});