Last active
May 11, 2022 06:25
-
-
Save andris9/938a73247b1e76ec515293f580dfa802 to your computer and use it in GitHub Desktop.
zonemta authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# store to config/plugins/authplugin.toml | |
[authplugin] | |
enabled="receiver" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
autphlugin.js
is a typo - it should beauthplugin.js
- Unfortunately, I can't seem to get the authentication working. @andris9