Builting ZoneMTA with the plugins
This commit is contained in:
parent
77c64f487d
commit
1ebf808724
7 changed files with 1635 additions and 1 deletions
1
zone-mta
1
zone-mta
|
@ -1 +0,0 @@
|
||||||
Subproject commit 7990c49dda71c8cb65ddd83da3b785711d26894b
|
|
97
zone-mta/config/zonemta.js
Normal file
97
zone-mta/config/zonemta.js
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
// This is the main config file
|
||||||
|
name: 'ZoneMTA',
|
||||||
|
|
||||||
|
// Process identifier
|
||||||
|
ident: 'zone-mta',
|
||||||
|
|
||||||
|
// Run as the following user. Only use this if the application starts up as root
|
||||||
|
// user: "zonemta"
|
||||||
|
// group: "zonemta"
|
||||||
|
|
||||||
|
log: {
|
||||||
|
level: 'info'
|
||||||
|
},
|
||||||
|
|
||||||
|
dbs: {
|
||||||
|
// MongoDB connection string
|
||||||
|
mongo: 'mongodb://127.0.0.1:27017/zone-mta',
|
||||||
|
|
||||||
|
// Redis connection string
|
||||||
|
redis: 'redis://localhost:6379/2',
|
||||||
|
|
||||||
|
// Database name for ZoneMTA data in MongoDB. In most cases it should be the same as in the connection string
|
||||||
|
sender: 'zone-mta'
|
||||||
|
},
|
||||||
|
|
||||||
|
api: {
|
||||||
|
maildrop: false,
|
||||||
|
user: 'mailtrain',
|
||||||
|
pass: 'mailtrain'
|
||||||
|
},
|
||||||
|
|
||||||
|
smtpInterfaces: {
|
||||||
|
// Default SMTP interface for accepting mail for delivery
|
||||||
|
feeder: {
|
||||||
|
enabled: true,
|
||||||
|
|
||||||
|
// How many worker processes to spawn
|
||||||
|
processes: 1,
|
||||||
|
|
||||||
|
// Maximum allowed message size 30MB
|
||||||
|
maxSize: 31457280,
|
||||||
|
|
||||||
|
// Local IP and port to bind to
|
||||||
|
host: '127.0.0.1',
|
||||||
|
port: 2525,
|
||||||
|
|
||||||
|
// Set to true to require authentication
|
||||||
|
// If authentication is enabled then you need to use a plugin with an authentication hook
|
||||||
|
authentication: true,
|
||||||
|
|
||||||
|
// How many recipients to allow per message
|
||||||
|
maxRecipients: 1,
|
||||||
|
|
||||||
|
// Set to true to enable STARTTLS. Do not forget to change default TLS keys
|
||||||
|
starttls: false,
|
||||||
|
|
||||||
|
// set to true to start in TLS mode if using port 465
|
||||||
|
// this probably does not work as TLS support with 465 in ZoneMTA is a bit buggy
|
||||||
|
secure: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
"core/email-bounce": false,
|
||||||
|
"core/http-bounce": {
|
||||||
|
enabled: "main",
|
||||||
|
url: "http://localhost:3000/webhooks/zone-mta"
|
||||||
|
},
|
||||||
|
"core/default-headers": {
|
||||||
|
enabled: ["receiver", "main", "sender"],
|
||||||
|
futureDate: false,
|
||||||
|
xOriginatingIP: false
|
||||||
|
},
|
||||||
|
'mailtrain-main': {
|
||||||
|
enabled: ['main']
|
||||||
|
},
|
||||||
|
'mailtrain-receiver': {
|
||||||
|
enabled: ['receiver'],
|
||||||
|
username: 'mailtrain',
|
||||||
|
password: 'mailtrain'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
zones: {
|
||||||
|
default: {
|
||||||
|
preferIPv6: false,
|
||||||
|
ignoreIPv6: true,
|
||||||
|
processes: 1,
|
||||||
|
connections: 5,
|
||||||
|
pool: 'default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
4
zone-mta/index.js
Normal file
4
zone-mta/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// start the app
|
||||||
|
require('zone-mta');
|
1456
zone-mta/package-lock.json
generated
Normal file
1456
zone-mta/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
22
zone-mta/package.json
Normal file
22
zone-mta/package.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "mailtrain-zone-mta",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Mailtrain builtin ZoneMTA instance",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js --config=config/zonemta.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"homepage": "https://mailtrain.org/",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"zone-mta": "1.13.3",
|
||||||
|
"zonemta-delivery-counters": "1.0.1",
|
||||||
|
"zonemta-limiter": "1.0.0",
|
||||||
|
"zonemta-loop-breaker": "1.0.2"
|
||||||
|
}
|
||||||
|
}
|
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