Commit graph

258 commits

Author SHA1 Message Date
Bojan Čekrlić
5f441fb7a2 Fix for #39 - Make sure private keys are readable by OpenDKIM
Private keys generated with `DKIM_AUTOGENERATE` were created with
the root account and as such were not readable by OpenDKIM.

This fix will reown the created files to the `opendkim` user.
2020-10-24 21:24:18 +02:00
Bojan Čekrlić
9a33ade483 Fix for #37
While quite annoying behavour, this is the how `postconf` works.
If you tell it to comment out a command, it will add it to the config
even when the same command exists commented out in the config file.

This commit does a bit of sed and grep magic to find if the comment
already exists and if yes, then it does nothing.
2020-10-24 21:24:18 +02:00
Bojan Čekrlić
1569848df0 Updated tester tool to use the tool-downloader 2020-10-24 21:24:18 +02:00
Bojan Čekrlić
5aca4e36dc Normalize whitespace
Make sure that all whitespaces are the same -- spaces have been
converted to tabs.
2020-10-24 21:24:18 +02:00
Boky
9124555f2b
Fix hostname variable change in README.md
Apparently, `README.md` still referenced the old `HOSTNAME` variable.

This should fix the issue.
2020-08-20 08:45:29 +02:00
Boky
4031e176be
Fix typo in README.md 2020-08-20 08:43:11 +02:00
Antoine GC
aa6d2dcc45
Fix a wrongly named variable in README.md (#32)
Fix wrongly named postfix variable (`POSTFIX_hostname` -> `POSTFIX_myhostname`)
2020-08-20 08:21:53 +02:00
Antoine GC
2b577f3522
Update common-run.sh (#31)
To fix an issue when multiple domains in ALLOWED_SENDER_DOMAINS, DKIM signature only works for one domain
2020-08-20 08:20:41 +02:00
Bojan Čekrlić
3f6d1330bb Simplify configuration
Postfix has an option to run in foreground. Use this feature to
reduce the complexity of supervisord.conf.
2020-08-15 23:52:22 +02:00
Bojan Čekrlić
35fa2d7acf Fix for #30 - Use sleep inifinity instead of sleep <number>
Apparently using sleep with very large numbers is not a good idea
when your image can be compiled down to 32-bit platforms.

This fix uses `sleep infinity` and -- failing that -- tries to
sleep for about 68 years (which is exactly 2^15 seconds).
2020-08-15 22:47:49 +02:00
Boky
4d12408b5d
Update README.md 2020-07-29 11:36:48 +02:00
Boky
bf9b001b06
Add license scan report and status (#28)
Signed off by: fossabot <badges@fossa.com>

Co-authored-by: fossabot <badges@fossa.io>
2020-07-29 11:36:03 +02:00
Bojan Čekrlić
cfd1a13676 Deprecate some common properties and add auto-generation of DKIM keys 2020-07-03 07:08:27 +02:00
Bojan Čekrlić
c460941b90 Fix for #24 + some new integration tests 2020-07-01 14:12:04 +02:00
Bojan Čekrlić
ff2d080279 Add the option to log to rsyslog as plain or JSON and restructure tests
- It's now possible to choose the logging type - either 'plain' or
  'json'
- The code is ready to support multiple integration tests (with
  different configurations)
- `OPENDKIM_` and `POSTFIX_` variables are handled properly and recorded
  in the corresponding files. (This had a downfall that `bash` now needs
  to be installed, so we can probably simplify some of the shell
  scripts.)
2020-07-01 13:50:08 +02:00
Bojan Čekrlić
9b1902c047 Larger refactoring of the codebase + DKIM_SELECTOR
Summary
^^^^^^^

This commit refactors the code base to be more manageble and
prepares the groundwork for tests.

Refactoring
^^^^^^^^^^^

Files are now moved to subdirectories, all for the sole purpose of
easier management. Tests live in their own folders, as well as configs
and other files.

Test framework
^^^^^^^^^^^^^^

Two new important scripts/directories are available:
- `unit-tests.sh` / `/unit-test` which executes unit tests across shell
  scripts, and
- `integration-test.sh` / `integration-tests`, which spins up the
  container and tries to send the email.

Both tests use the [BATS](https://github.com/sstephenson/bats) framework
for testing. To create a new test, simply drop a `.bats` file into a
corresponding directory.

Functions have been extracted into `common-run.sh`, to be able to test
them independently.

DKIM_SELECTOR
^^^^^^^^^^^^^

It is now possible to specify a DKIM selector to use (instead of
the default "mail"). See `README.md` for more details.

JSON logging
^^^^^^^^^^^^

WIP: rsyslog will now output JSON logs. This is especially important
if you plan on deploying the image into Kubernetes, as [Prometheus](https://prometheus.io/)
can handle logs in JSON much easier.

TODO: Make this an optional feature, to not confuse existing users.
2020-06-29 19:03:24 +02:00
Boky
ed09d86c8d
Update documentation on port 25 blocking
Expand the `README.md` a bit to better explain what's needed to get the server up and running.

It seems that a lot of users are trying to use this image and running into issues. This should help out a bit to get them started.
2020-03-16 08:34:21 +01:00
Bojan Čekrlić
8a9002566f Remove build for linux/s390x 2020-01-31 21:18:02 +01:00
Bojan Čekrlić
1caf4104ba Move from Docker Hub builds to GitHub Actions
This allows us to create do a multi-arch build, resulting in
an image which is useful even on low-end IoT devices.
2020-01-31 21:07:42 +01:00
Matthew Critchlow
0feeccbfc3
Support alpine versions (#20)
* Support multiple alpine versions in Dockerfile

Add an ARG to the Dockerfile to support passing in build-args when
running docker build to support different alpine base image versions.

* Create push.sh script for managing image updates

The push.sh script supports passing multiple alpine tags which will then
be built, tagged, and pushed to docker hub
2020-01-31 21:01:29 +01:00
Boky
0f4bd837d0
Additional documentation about ALLOW_EMPTY_SENDER_DOMAINS
Updated `README.md` to make it more clear how to use `ALLOW_EMPTY_SENDER_DOMAINS`.
2019-10-20 18:38:31 +02:00
Andrés Álvarez
8fda5d9004 Decouple commons.sh from run.sh (#18)
Use case is being able to reuse the common methods when extending the image so that the behavior is consistent (e.g: same formatting for log messages) without needing to repeat the code while extending.
2019-10-20 18:34:27 +02:00
Andrés Álvarez
074125ffe1 Allow setting empty ALLOWED_SENDER_DOMAINS (#17)
This PR allows setting an empty `ALLOWED_SENDER_DOMAINS` variable. The default behaviour remains the same (empty `ALLOWED_SENDER_DOMAINS` will throw an error), but it is posible to override this behaviour via a new variable `ALLOW_EMPTY_SENDER_DOMAINS`.
2019-10-20 18:33:08 +02:00
Bojan Čekrlić
f4448d6d9e Rename HEADER_CHECKS to SMTP_HEADER_CHECKS 2019-10-03 09:32:39 +02:00
malware-watch
a9a09b0085 Added HEADER_CHECKS configuration option (#15)
* Added HEADER_CHECKS  configuration option
2019-10-03 09:01:53 +02:00
Bojan Čekrlić
4d6919e54c Add additional headers to DKIM signature
By default OpenDKIM will sign just `From`, `To`, `Sender`,
`Subject` and `Date`.

It makes sense to also sign other headers (especially `Reply-To`)
to make sure nobody fiddles with the email.
2019-09-17 09:31:42 +02:00
Bojan Čekrlić
ecfb59dffd Relax OpenDKIM TrustedHosts
Having very specific `TrustedHosts` has turned out to be more of a
hassle than a benefit in the end.

Since the service is runing on `localhost` either way, there's no
theoretical way for anybody alse to access the service. Hence we
just set all hosts (`0.0.0.0/0`) to trusted, reduce the LOC and
call it a day.
2019-09-17 09:11:53 +02:00
Bojan Čekrlić
f971f1efd2 Fix for #12 where Alpine 3.9 split cyrus-sasl into multiple packages: https://bugs.alpinelinux.org/issues/9987 2019-05-13 13:28:55 +02:00
Bojan Čekrlić
cd4f64a8ce Fixes for DKIM implementation
Important note: DKIM segment is hardcoded to "mail" in the
configuration.

You shouldn't be using any other segment name.

If you don't know what that means: DKIM checks your DNS server
for this segment name by querying `<segment>._domainkey.<domain>`.

So, when saying you need to use the `mail` segment this means that
the record *must* reside under `mail._domainkey.<domain>`.
2019-03-07 08:29:50 +01:00
Bojan Čekrlić
d8873c8efb Merge branch 'master' of github.com:bokysan/docker-postfix 2019-03-07 08:29:33 +01:00
Bojan Čekrlić
456e00e8b4 DomainKeys fixes
This fix makes it more explicit that "mail" segment must be used
with this DKIM and adds a few more code to the DKIM part to make
it more resillient and useful.
2019-03-06 13:07:26 +01:00
Matias
6cbb7d0837 Add packages needed to authenticate to gmail (#10)
* Add packages needed to correctly authenticate using a gmail relay
* Squishing 'apk add' lines
2019-02-25 14:28:16 +01:00
Bojan Čekrlić
a1cffc6b23 More resillient builds
It turns out that builds cannot be predictable - different accounts
were assigned by different build systems. Consequentially we install
each tool separately.
2019-02-19 12:08:13 +01:00
Bojan Čekrlić
38d7627d96 OpenDKIM keys have been moved to the keys folder
This is to make it easier to integrate with Kubernetes to be able
to bind a `ConfigMap` to the said folder.
2019-02-19 11:42:16 +01:00
Bojan Čekrlić
afccfdb3fc Fixed typo 2019-02-19 11:02:51 +01:00
Bojan Čekrlić
928e5d64c7 Initial support for DKIM and testing
This commit brings two important features:
- **DKIM support** It's now possible to configure this postfix
  image to sign messages using DKIM by simply generating the keys
  and providing them in the approprate folder. This should bring
  us one step closer to directly sending out emails without relying
  on a 3rd-party proxy.
- **test support** A nice and handy script, conviniently called
  `test.sh` has been provided, builds the image, spins it up and
  tries to send out an email. You'll need `docker-compose` to run
  it, though.
2019-02-19 10:49:55 +01:00
Bojan Čekrlić
d7b6bdc32c Added the possibility to masquarade domains
This patch was "borrowed" from a fork of this project by RescueTime
and seemed like a good feature to include in the project.
2019-02-19 08:59:02 +01:00
Bojan Čekrlić
aa66569ac1 Major update, better support for handling TLS connections.
This update includes a few features that make it easier to work
with relay hosts. The configuration now uses built-in (Alpine) TLS
certificates and allows the user to specify how the Postfix should
establish a TLS connection. Configure it using `RELAYHOST_TLS_LEVEL`,
if needed.

Another configuration option was added, `MESSAGE_SIZE_LIMIT`, which
enables you to reject messages exceeding certain limits. Especially
useful with relay servers, to prevent messages getting stuck in
Postfix queue.

Use the `INBOUND_DEBUGGING` parameter to enable additional postfix
logs for incoming messages when things go south.

Use `TZ` parameter to set the timezone of the container (especially
useful for logs and dates in the messages).

*Notice that `ALLOWED_SENDER_DOMAINS` is now a neccessary parameter.*
Turns out that due to Postfix anti-spam configuration there's no way
to start it properly without specifying the domains it will relay
email for.

This commit also includes a few samples of running the container:
- standalone
- in [docker-compose](https://docs.docker.com/compose/)

Further work: add a working Kubernetes / Helm chart example.
2019-01-02 14:06:00 +01:00
Florian Probst
9254d5ef36 added ca-certs and tls authentication (#9) 2019-01-02 09:50:52 +01:00
Bojan Čekrlić
397c0ce838 Swiched from alpine:edge to alpine:latest. Fixed some typos. 2018-11-13 12:05:58 +01:00
Boky
cef2d06d3d
Update README.md 2018-11-13 11:56:18 +01:00
Boky
fa4a3b8646
Update README.md 2018-11-13 11:55:27 +01:00
Boky
33a893d22a
Updated README.md 2018-11-13 11:54:38 +01:00
Boky
e95e1a5a9c
Create CODE_OF_CONDUCT.md 2018-10-06 16:50:49 +02:00
Boky
fc47db0529
Fixed a typo in readme 2018-10-06 16:48:00 +02:00
Bojan Čekrlić
707b8407e4 Additional fix when no domain given. 2018-07-31 15:04:00 +02:00
Bojan Čekrlić
bd4b3ce754 Relax SMTPD accept and relay restrictions.
There are some use cases when using `reject_unverified_recipient`
(http://www.postfix.org/postconf.5.html#reject_unverified_recipient)
doesn't seem to be as good idea. This patch fixes this.

While in theory it seems good, in practice (for our use case) it's not:
- the service cannot send out emails as fast, as each "RCPT TO" will
result in a DNS lookup (and connection to the target server), which can
slow things down considerably.
- the target server might just be busy or temporarily offline. This will
prevent the service from sending out the email, which defeats the
purpose of mail bagging.
- we might be behind a firewall and not even be able to connect to the
target server for email validation

Furthermore, this patch include the following line:
`smtpd_relay_restrictions = permit`

This basically opens up relay functionality to any address. Previously
there was an issue if you wanted to send an email to the address which
was listed in the `$ALLOWED_SENDER_DOMAINS`.
2018-07-30 08:30:14 +02:00
Bojan Čekrlić
0638d349bd Minor edits for easier understanding.
The Dockerfile has been reformatted a bit to make it more clear and easy
to understand. README.md has been updated with the postfix's user
account details.
2018-07-27 16:42:35 +02:00
Bojan Čekrlić
50ad64dc4e Updated documentation, added info about project status. 2018-07-19 08:49:51 +02:00
Bojan Čekrlić
2797040faa NEW FEATURE: A new feature has been added -- it's now posible to specify a RELAY
hosts's username and password, if your remote host requires
authentication.

NEW FEATURE: The possibility to execute third party scripts. This should
make extending this image easier.

REFACTORING: Dockerfile now starts with run.sh instead of suprevisor.
This makes it much easier to see any errors that might creep into the
code. Also note that the script now relies on POSIX-compliant commands
only so the executor has been changed from /bin/bash to /bin/sh.
2017-11-02 14:20:28 +01:00