Skip to content

Implementation of multi-domain relay hosts, fixes #922#926

Merged
johansmitsnl merged 5 commits intodocker-mailserver:masterfrom
crazystick:issue-922
Apr 2, 2018
Merged

Implementation of multi-domain relay hosts, fixes #922#926
johansmitsnl merged 5 commits intodocker-mailserver:masterfrom
crazystick:issue-922

Conversation

@crazystick
Copy link
Copy Markdown
Contributor

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_map on-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.

…#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
@crazystick crazystick changed the title Implementation of multi-domain relay hosts, fixes 922 Implementation of multi-domain relay hosts, fixes #922 Mar 31, 2018
Copy link
Copy Markdown
Contributor

@johansmitsnl johansmitsnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread target/bin/addrelayhost Outdated
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a new line

Comment thread target/bin/addsaslpassword Outdated
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment thread README.md
#### RELAY_PASSWORD

- **empty** => no default
- password for default relay user
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the env and the setup script independently or dos the env needs to be set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@crazystick
Copy link
Copy Markdown
Contributor Author

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
@crazystick
Copy link
Copy Markdown
Contributor Author

I think I'm done. All the tests pass for me. I'll add a wiki page if the PR gets merged!

@johansmitsnl johansmitsnl merged commit f28e984 into docker-mailserver:master Apr 2, 2018
johansmitsnl added a commit that referenced this pull request Apr 23, 2018
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants