Builting ZoneMTA with the plugins
This commit is contained in:
parent
77c64f487d
commit
1ebf808724
7 changed files with 1635 additions and 1 deletions
14
zone-mta/plugins/mailtrain-main.js
Normal file
14
zone-mta/plugins/mailtrain-main.js
Normal 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();
|
||||
};
|
42
zone-mta/plugins/mailtrain-receiver.js
Normal file
42
zone-mta/plugins/mailtrain-receiver.js
Normal 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();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue