Skip to content

Instantly share code, notes, and snippets.

@andris9
Created March 29, 2018 07:10
Show Gist options
  • Save andris9/7114ae3dd400a0eccd0d8c3a3a112933 to your computer and use it in GitHub Desktop.
Save andris9/7114ae3dd400a0eccd0d8c3a3a112933 to your computer and use it in GitHub Desktop.
Custom routing plugin
// store as plugins/customrouter.js
'use strict';
module.exports.title = 'Custom router';
module.exports.init = function(app, done) {
// Set up custom MX for a delivery
app.addHook('sender:fetch', (delivery, next) => {
delivery.mx = [{
priority: 0,
exchange: app.config.hostname,
A: [].concat(app.config.ip4 || []),
AAAA: [].concat(app.config.ip6 || [])
}];
delivery.mxPort = app.config.mxPort;
next();
});
done();
};
# store as config/plugins/customrouter.toml
[customrouter]
enabled="sender"
# MX hostname
hostname="example.com"
# MX IPv4, either IP string or an array of IP addresses
ip4="127.0.0.1"
# MX IPv6, optional
#ip6="::1"
@atikulhaider
Copy link

atikulhaider commented May 26, 2018

Dear Andris,
I'm a beginner.
I can't figure out how to configure external relay for all outgoing mail. Here is what I want: http://www.postfix.org/postconf.5.html#relayhost
Like postfix relayhost, I want to route all my outgoing mails through another relay, say through an Cloud Antispam gateway.
On postfix, if I add just this line: relayhost = relay.symantec.com:25 all done.
How can I achieve this with ZoneMTA please? I have moved customrouter.js to plugins folder & customrouter.toml to config/plugins folder. Then added the lines below to production.json file inside plugins:
"customrouter": { "enabled": ["sender"], "host": "relay.symantec.com", "port": 25
Doesn't work as I can't figure it out. Please help me.

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