docs(refactor): Restructure document hierarchy

Additionally rename `installation-examples.md` and split
This commit is contained in:
wernerfred 2021-03-01 20:50:18 +01:00 committed by polarathene
parent 021e942c4c
commit 1a8552b96c
16 changed files with 123 additions and 123 deletions

View file

@ -0,0 +1,35 @@
---
title: 'Mail Forwarding | AWS SES'
---
!!! note
New configuration, see [Configure Relay Hosts][docs-relay]
Instead of letting postfix deliver mail directly it is possible to configure it to deliver outgoing email via Amazon SES (Simple Email Service). (Receiving inbound email via SES is not implemented.) The configuration follows the guidelines provided by AWS in https://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html, specifically, the `STARTTLS` method.
As described in the AWS Developer Guide you will have to generate SMTP credentials and define the following two environment variables in the docker-compose.yml with the appropriate values for your AWS SES subscription (the values for `AWS_SES_USERPASS` are the "SMTP username" and "SMTP password" provided when you create SMTP credentials for SES):
```yaml
environment:
- AWS_SES_HOST=email-smtp.us-east-1.amazonaws.com
- AWS_SES_USERPASS=AKIAXXXXXXXXXXXXXXXX:kqXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```
If necessary, you can also provide `AWS_SES_PORT`. If not provided, it defaults to 25.
When you start the container you will see a log line as follows confirming the configuration:
```log
Setting up outgoing email via AWS SES host email-smtp.us-east-1.amazonaws.com
```
To verify proper operation, send an email to some external account of yours and inspect the mail headers. You will also see the connection to SES in the mail logs. For example:
```log
May 23 07:09:36 mail postfix/smtp[692]: Trusted TLS connection established to email-smtp.us-east-1.amazonaws.com[107.20.142.169]:25:
TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
May 23 07:09:36 mail postfix/smtp[692]: 8C82A7E7: to=<someone@example.com>, relay=email-smtp.us-east-1.amazonaws.com[107.20.142.169]:25,
delay=0.35, delays=0/0.02/0.13/0.2, dsn=2.0.0, status=sent (250 Ok 01000154dc729264-93fdd7ea-f039-43d6-91ed-653e8547867c-000000)
```
[docs-relay]: ./relay-hosts.md

View file

@ -0,0 +1,90 @@
---
title: 'Mail Forwarding | Relay Hosts'
---
## Introduction
Rather than having Postfix deliver mail directly, you can configure Postfix to send mail via another mail relay (smarthost). Examples include [Mailgun](https://www.mailgun.com/), [Sendgrid](https://sendgrid.com/) and [AWS SES](https://aws.amazon.com/ses/).
Depending on the domain of the sender, you may want to send via a different relay, or authenticate in a different way.
## Basic Configuration
Basic configuration is done via environment variables:
* **RELAY_HOST** _default host to relay mail through, empty will disable this feature_
* **RELAY_PORT** _port on default relay, defaults to port 25_
* **RELAY_USER** _username for the default relay_
* **RELAY_PASSWORD** _password for the default user_
Setting these environment variables will cause mail for all sender domains to be routed via the specified host, authenticating with the user/password combination.
!!! note
For users of the previous `AWS_SES_*` variables: please update your configuration to use these new variables, no other configuration is required.
## Advanced Configuration
### Sender-dependent Authentication
Sender dependent authentication is done in `config/postfix-sasl-password.cf`. You can create this file manually, or use:
```sh
setup.sh relay add-auth <domain> <username> [<password>]
```
An example configuration file looks like this:
```txt
@domain1.com relay_user_1:password_1
@domain2.com relay_user_2:password_2
```
If there is no other configuration, this will cause Postfix to deliver email throught the relay specified in `RELAY_HOST` env variable, authenticating as `relay_user_1` when sent from `domain1.com` and authenticating as `relay_user_2` when sending from domain2.com.
!!! note
To activate the configuration you must either restart the container, or you can also trigger an update by modifying a mail account.
### Sender-dependent Relay Host
Sender dependent relay hosts are configured in `config/postfix-relaymap.cf`. You can create this file manually, or use:
```sh
setup.sh relay add-domain <domain> <host> [<port>]
```
An example configuration file looks like this:
```txt
@domain1.com [relay1.org]:587
@domain2.com [relay2.org]:2525
```
Combined with the previous configuration in `config/postfix-sasl-password.cf`, this will cause Postfix to deliver mail sent from domain1.com via `relay1.org:587`, authenticating as `relay_user_1`, and mail sent from domain2.com via `relay2.org:2525` authenticating as `relay_user_2`.
!!! note
You still have to define `RELAY_HOST` to activate the feature
### Excluding Sender Domains
If you want mail sent from some domains to be delivered directly, you can exclude them from being delivered via the default relay by adding them to `config/postfix-relaymap.cf` with no destination. You can also do this via:
```sh
setup.sh relay exclude-domain <domain>
```
Extending the configuration file from above:
```txt
@domain1.com [relay1.org]:587
@domain2.com [relay2.org]:2525
@domain3.com
```
This will cause email sent from domain3.com to be delivered directly.
#### References
Thanks to the author of [this article][1] for the inspiration. This is also worth reading to understand a bit more about how to set up Mailgun to work with this.
[1]: https://community.rackspace.com/products/f/email-products-forum/3897/how-to-setup-postfix-with-a-mailgun-smtp-relay-when-using-multiple-domains