Builting ZoneMTA with the plugins

This commit is contained in:
Tomas Bures 2018-12-16 22:44:50 +01:00
parent 77c64f487d
commit 1ebf808724
7 changed files with 1635 additions and 1 deletions

View file

@ -0,0 +1,14 @@
'use strict';
// Set module title
module.exports.title = 'Mailtrain integration (main)';
// Initialize the module
module.exports.init = (app, done) => {
process.send({
type: 'zone-mta-started'
});
done();
};

View file

@ -0,0 +1,42 @@
'use strict';
// Set module title
module.exports.title = 'Mailtrain integration (receiver)';
// Initialize the module
module.exports.init = (app, done) => {
app.addHook('message:headers', (envelope, messageInfo, next) => {
const headers = envelope.headers;
if (!envelope.dkim.keys) {
envelope.dkim.keys = [];
}
const dkimHeaderValue = headers.getFirst('x-mailtrain-dkim');
if (dkimHeaderValue) {
const dkimKey = JSON.parse(dkimHeaderValue);
envelope.dkim.keys.push(dkimKey);
headers.remove('x-mailtrain-dkim');
}
return next();
});
app.addHook('smtp:auth', (auth, session, next) => {
if (auth.username === app.config.username && auth.password === app.config.password) {
next();
} else {
// do not provide any details about the failure
const err = new Error('Authentication failed');
err.responseCode = 535;
return next(err);
}
});
// all set up regarding this plugin
done();
};