Implementation of multi-domain relay hosts, fixes #922#926
Implementation of multi-domain relay hosts, fixes #922#926johansmitsnl merged 5 commits intodocker-mailserver:masterfrom
Conversation
…#922) * Creates new environment variables (replacing existing AWS_SES variables) * Optionally allows more advanced setups using config files
Add helper scripts for adding relay hosts and per-domain auth
johansmitsnl
left a comment
There was a problem hiding this comment.
Looks good. Please see minor notes.
Can you also add tests for the setup script (there are some already available).
The delivery is hard to test, you could verify that the env variable are set correctly in the docker instance.
| sed -i "s ^@"$DOMAIN".* "@$DOMAIN"\t\t["$HOST"]:"$PORT" " $DATABASE | ||
| else | ||
| echo -e "@$DOMAIN\t\t[$HOST]:$PORT" >> $DATABASE | ||
| fi No newline at end of file |
There was a problem hiding this comment.
Could you add a new line
| sed -i "s ^@"$DOMAIN".* "@$DOMAIN"\t\t"$USER":"$PASSWD" " $DATABASE | ||
| else | ||
| echo -e "@$DOMAIN\t\t$USER|$PASSWD" >> $DATABASE | ||
| fi No newline at end of file |
| #### RELAY_PASSWORD | ||
|
|
||
| - **empty** => no default | ||
| - password for default relay user |
There was a problem hiding this comment.
Can you use the env and the setup script independently or dos the env needs to be set?
There was a problem hiding this comment.
as it stands, at least the RELAY_HOST env variable is required, and the config files add functionality on top (the env variables alone basically work like the AWS_SES_* vars used to work). It would be possible to drop the env and do it all by config files, but then we have to keep the AWS_SES code for backwards compatibiilty. I believe that unauthenticated relays are possible (although dangerous) so I think it's valid to have relay user/password be optional.
adding a domain with no destination will exclude it from the relayhost_map and so Postfix will attempt to deliver the mail directly
|
Tests for setup.sh are working. I will try to add some more tests that verify that the start-mailserver.sh script actually generates the expected config files, but I can't see how to test the actual delivery without relying on external resources, and I think that would make the build pretty fragile. |
these tests cover the code in `start-mailserver.sh` dealing with both the env vars and the configuration files
|
I think I'm done. All the tests pass for me. I'll add a wiki page if the PR gets merged! |
Release 6.0.0 * Implementation of multi-domain relay hosts (#922, #926) AWS_SES_HOST and AWS_SES_PORT are deprecated now. RELAY_HOST and RELAY_PORT are introduced to replace them. * Password creation fix (#908, #914) * Fixes 'duplicate log entry for /var/log/mail/mail.log' (#925, #927) * fixed cleanup (mail_with_relays didn't get cleaned up) (#930) * fix line breaks in postfix-summary mail error case (#936) * Set default virus delete time (#932, #935) This defaults to 7 days * Ensure that the account contains a @ (#923, #924) * Introducing global filters. (#934) * add missing env vars to docker-compose.yml (#937) * set postmaster address to a sensible default (#938, #939, #940)
The implementation is pretty much as per the description in #922
There is a bit of additional flexibility vs. what I planned - you can add relay maps to postfix-relaymap.cf which allows for per-domain relay hosts as well as per-domain authentication. I have tested that successfully having one domain send via Mailgun and another send via Sendgrid.
This implementation is pretty convenient for my use-case - however it did occur to me that we could require users to build the whole configuration in those two config files, and skip building
/etc/postfix/relayhost_mapon-the-fly from mail accounts. That would reduce the amount of code somewhat.I didn't spot any tests for AWS_SES env variables, and so I'm not sure quite how this should be tested. Any advice would be appreciated.