Skip to content

Instantly share code, notes, and snippets.

@andris9
Last active May 11, 2022 06:25
Show Gist options
  • Save andris9/938a73247b1e76ec515293f580dfa802 to your computer and use it in GitHub Desktop.
Save andris9/938a73247b1e76ec515293f580dfa802 to your computer and use it in GitHub Desktop.
zonemta authentication
# store to config/plugins/authplugin.toml
[authplugin]
enabled="receiver"
// store to plugins/authplugin.js
'use strict';
const username = 'user';
const password = 'secret';
module.exports.title = 'Simple Authentication';
module.exports.init = function(app, done) {
// Listen for AUTH command
app.addHook('smtp:auth', (auth, session, next) => {
if (auth.username !== username || auth.password !== password) {
// authentication failed
let err = new Error('Authentication failed');
err.responseCode = 535;
return next(err);
}
// consider the authentication as succeeded as we did not get an error
next();
});
done();
};
@roshanjonah
Copy link

autphlugin.js is a typo - it should be authplugin.js - Unfortunately, I can't seem to get the authentication working. @andris9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment