Created
March 29, 2018 07:10
-
-
Save andris9/7114ae3dd400a0eccd0d8c3a3a112933 to your computer and use it in GitHub Desktop.
Custom routing plugin
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 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(); | |
| }; |
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 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:25all 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": 25Doesn't work as I can't figure it out. Please help me.