24 Commits

Author SHA1 Message Date
Victor
e0b14a4514 Add CI with GitHub Actions 2021-04-24 16:19:47 -05:00
Ernesto Baschny
b1ef5ea1d0 Allow to use a SMTP server without authentication 2021-03-30 16:35:54 -05:00
Juan Luis Baptiste
2264af0bca Add smtp_host_lookup=native,dns parameter
to allow the lookup of hosts added to /etc/hosts file via docker options
(issue #51).
2021-03-17 17:17:39 -05:00
Juan Luis Baptiste
9b1d5b47a7 Added bug reporting template 2021-02-03 19:14:12 -05:00
Juan Luis Baptiste
7c3a0cacb5 Added .gitignore file 2021-02-03 18:41:00 -05:00
Juan Luis Baptiste
e674820a5c Updated README.md with info about new default alpine image 2021-02-03 18:40:28 -05:00
Juan Luis Baptiste
273beb03fa Merged migrate_to_alpine branch into master (issue #16) 2021-02-03 18:40:00 -05:00
Juan Luis Baptiste
d5012c2652 Fix broken build status badge 2021-01-18 18:42:55 -05:00
Rev (Tsuyoshi Yamasaki)
8cc737c70a add smtp_tls_wrappermode and smtp_tls_security_level.
You need both parameters when you send emails with TLS(465).
2021-01-02 14:06:46 -05:00
Tom Stein
4398bb1053 Fix wrong description in .env.template
The old comment was wrongly copy-pasted
2020-12-02 10:30:45 -05:00
Tom Stein
5e4998f14e fix broken link in Readme
The docker-compose file was renamed
2020-12-02 10:29:42 -05:00
David Cooper
bb8a0671d7 Fix issue #35 2020-11-01 17:16:09 -05:00
lucas_nz
29b356bb2b include OVERWRITE_FROM in .env.example 2020-10-11 12:52:33 -05:00
lucas_nz
99a2397715 Add option to overwrite the From address 2020-10-11 12:52:15 -05:00
Erik Martin-Dorel
c55bcb70ac Add option always_add_missing_headers (#31)
(adding From:, To:, Date: or Message-ID: headers when not present,
cf. http://www.postfix.org/postconf.5.html#always_add_missing_headers)

This option always_add_missing_headers is set by the environment
variable ALWAYS_ADD_MISSING_HEADERS (default: no)
2020-08-24 14:40:09 -05:00
Juan Luis Baptiste
9603b4070d Updated blog address 2020-06-24 21:54:14 -05:00
dabde
af1f46641b Add function to load secret/password from file for security (#25)
New feature: Load SMTP password from file to avoid using env variables.
2020-06-19 16:52:21 -05:00
Juan Luis Baptiste
74ea38cd6e Update docker-compose file name to renamed docker-compose.override.yml name. Fixes issue #28. 2020-06-03 10:00:36 -05:00
Juan Luis Baptiste
113fe1c53d Added LICENSE file to fix issue #27 2020-05-27 14:43:09 -05:00
Juan Luis Baptiste
b549ac8228 Renamed docker-compose.dev.yml to docker-compose.override.yml so it
does not need to be explicitly set to build the image.
2020-04-09 12:23:20 -05:00
Juan Luis Baptiste
e6b37122f8 Added an example .env file 2020-04-09 12:13:45 -05:00
Juan Luis Baptiste
0ec4289588 Added information about the migration to Alpine 2020-03-24 12:11:20 -05:00
Juan Luis Baptiste
32fa6bcd68 Merge pull request #19 from solidnerd/patch-1
fix(postfix): Set correct default value for SMTP_PORT
2020-01-21 10:52:43 -05:00
Niclas Mietz
0e9c2d2b23 fix(postfix): Set correct default value for SMTP_PORT 2020-01-21 10:47:27 +01:00
8 changed files with 143 additions and 19 deletions

View File

@@ -5,10 +5,10 @@
# Optional: (Default value: 587) Port address of the SMTP server to use. # Optional: (Default value: 587) Port address of the SMTP server to use.
#SMTP_PORT= #SMTP_PORT=
# Mandatory: Username to authenticate with. # Optional: Username to authenticate with.
#SMTP_USERNAME= #SMTP_USERNAME=
# Mandatory: Password of the SMTP user. (Not needed if SMTP_PASSWORD_FILE is used) # Optional (Mandatory if SMTP_USERNAME is set): Password of the SMTP user. (Not needed if SMTP_PASSWORD_FILE is used)
#SMTP_PASSWORD= #SMTP_PASSWORD=
# Mandatory: Server hostname for the Postfix container. Emails will appear to come from the hostname's domain. # Mandatory: Server hostname for the Postfix container. Emails will appear to come from the hostname's domain.
@@ -17,7 +17,7 @@
# Optional: This will add a header for tracking messages upstream. Helpful for spam filters. Will appear as "RelayTag: ${SMTP_HEADER_TAG}" in the email headers. # Optional: This will add a header for tracking messages upstream. Helpful for spam filters. Will appear as "RelayTag: ${SMTP_HEADER_TAG}" in the email headers.
#SMTP_HEADER_TAG= #SMTP_HEADER_TAG=
# Optional: This will add a header for tracking messages upstream. Helpful for spam filters. Will appear as "RelayTag: ${SMTP_HEADER_TAG}" in the email headers. # Optional: Setting this will allow you to add additional, comma seperated, subnets to use the relay. Used like SMTP_NETWORKS='xxx.xxx.xxx.xxx/xx,xxx.xxx.xxx.xxx/xx'.
#SMTP_NETWORKS= #SMTP_NETWORKS=
# Optional: Set this to a mounted file containing the password, to avoid passwords in env variables. # Optional: Set this to a mounted file containing the password, to avoid passwords in env variables.
@@ -27,4 +27,4 @@
#ALWAYS_ADD_MISSING_HEADERS=yes #ALWAYS_ADD_MISSING_HEADERS=yes
# Optional: This will rewrite the from address overwriting it with the specified address for all email being relayed. # Optional: This will rewrite the from address overwriting it with the specified address for all email being relayed.
#OVERWRITE_FROM="Your Name" <email@company.com> #OVERWRITE_FROM="Your Name" <email@company.com>

25
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,25 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Reporting a bug**
First of all, this is **not** a problem reporting forum, only report if you are pretty sure what you are experiencing is a bug with this image, not a configuration issue, for that you can use the [Github discussions section](https://github.com/juanluisbaptiste/docker-postfix/discussions) and we will do our best to help you to figure out what's going on with your setup.
Also be sure you are using the latest image by doing _docker pull juanluisbaptiste/postfix:latest_.
**Please include the contents of:**
* Your docker-compose.yml file
* Your .env file file
**Describe the issue**
Please include a description of what you are trying to accomplish and what you are facing when running this container.
**Expected behavior**
A clear and concise description of what you expected to happen.

48
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Release
on:
push:
tags:
- "*"
jobs:
docker:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.API_GITHUB_TOKEN }}
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: juanluisbaptiste/postfix
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{version}}
alpine
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}

36
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Test
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout with token
if: github.event_name != 'pull_request'
uses: actions/checkout@v2
with:
token: ${{ secrets.API_GITHUB_TOKEN }}
- name: Checkout without token
if: github.event_name == 'pull_request'
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Build Test
run: docker buildx build --load --tag test:test --file ./Dockerfile ./
- name: Version
if: github.event_name != 'pull_request'
uses: cycjimmy/semantic-release-action@v2.5.3
with:
semantic_version: 17.4
env:
GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

11
.releaserc.yml Normal file
View File

@@ -0,0 +1,11 @@
---
branches:
- name: master
- name: develop
prerelease: true
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- - "@semantic-release/github"
- successComment: false
failComment: false

View File

@@ -3,7 +3,7 @@
[![Docker Stars](https://img.shields.io/docker/stars/juanluisbaptiste/postfix.svg?style=flat-square)](https://hub.docker.com/r/juanluisbaptiste/postfix/) [![Docker Stars](https://img.shields.io/docker/stars/juanluisbaptiste/postfix.svg?style=flat-square)](https://hub.docker.com/r/juanluisbaptiste/postfix/)
[![Docker Pulls](https://img.shields.io/docker/pulls/juanluisbaptiste/postfix.svg?style=flat-square)](https://hub.docker.com/r/juanluisbaptiste/postfix/) [![Docker Pulls](https://img.shields.io/docker/pulls/juanluisbaptiste/postfix.svg?style=flat-square)](https://hub.docker.com/r/juanluisbaptiste/postfix/)
Simple Postfix SMTP TLS relay [docker](http://www.docker.com) image with no local authentication enabled (to be run in a secure LAN). Simple Postfix SMTP TLS relay [docker](http://www.docker.com) alpine based image with no local authentication enabled (to be run in a secure LAN).
It also includes rsyslog to enable logging to stdout. It also includes rsyslog to enable logging to stdout.
@@ -12,12 +12,11 @@ _If you want to follow the development of this project check out [my blog](https
### Available image tags ### Available image tags
This image has been built on CentOS 7 since its inception, but the new CentOS 8 does [not include supervisor](https://github.com/juanluisbaptiste/docker-postfix/issues/16) anymore, so I have started migrating this image to Alpine linux. So currently there are two image tags available: Currently we only handle a rolling release of new versions so only _latest_ tag is available, but there is [work in progress](https://github.com/juanluisbaptiste/docker-postfix/pull/29) to start releasing versioned images to be able to pin to specific versions in production deployments.
* juanluisbaptiste/postfix:latest, current CentOS 7 based image *_NOTES_*:
* juanluisbaptiste/postfix:alpine, new Alpine based image * The _alpine_ tag has been switched to use the master branch, but it's irrelevant as it is the same as _latest_.
* Old CentOS 7 based image is avaiable on the _centos_base_image branch_, but it is not being developed any more.
If testing goes well for some time, then the current CentOS image will be replaced by the new Alpine one, and _latest_ tag will point to it.
### Build instructions ### Build instructions
@@ -26,7 +25,7 @@ Clone this repo and then:
cd docker-Postfix cd docker-Postfix
sudo docker build -t juanluisbaptiste/postfix . sudo docker build -t juanluisbaptiste/postfix .
Or you can use the provided [docker-compose](https://github.com/juanluisbaptiste/docker-postfix/blob/master/docker-compose.overrides.yml) files: Or you can use the provided [docker-compose](https://github.com/juanluisbaptiste/docker-postfix/blob/master/docker-compose.override.yml) files:
sudo docker-compose build sudo docker-compose build
@@ -40,8 +39,8 @@ The following env variables need to be passed to the container:
* `SMTP_SERVER` Server address of the SMTP server to use. * `SMTP_SERVER` Server address of the SMTP server to use.
* `SMTP_PORT` (Optional, Default value: 587) Port address of the SMTP server to use. * `SMTP_PORT` (Optional, Default value: 587) Port address of the SMTP server to use.
* `SMTP_USERNAME` Username to authenticate with. * `SMTP_USERNAME` (Optional) Username to authenticate with.
* `SMTP_PASSWORD` Password of the SMTP user. If `SMTP_PASSWORD_FILE` is set, not needed. * `SMTP_PASSWORD` (Mandatory if `SMTP_USERNAME` is set) Password of the SMTP user. If `SMTP_PASSWORD_FILE` is set, not needed.
* `SERVER_HOSTNAME` Server hostname for the Postfix container. Emails will appear to come from the hostname's domain. * `SERVER_HOSTNAME` Server hostname for the Postfix container. Emails will appear to come from the hostname's domain.
The following env variable(s) are optional. The following env variable(s) are optional.

16
run.sh
View File

@@ -17,9 +17,8 @@ function add_config_value() {
if [ -n "${SMTP_PASSWORD_FILE}" ]; then [ -f "${SMTP_PASSWORD_FILE}" ] && read SMTP_PASSWORD < ${SMTP_PASSWORD_FILE} || echo "SMTP_PASSWORD_FILE defined, but file not existing, skipping."; fi if [ -n "${SMTP_PASSWORD_FILE}" ]; then [ -f "${SMTP_PASSWORD_FILE}" ] && read SMTP_PASSWORD < ${SMTP_PASSWORD_FILE} || echo "SMTP_PASSWORD_FILE defined, but file not existing, skipping."; fi
[ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1 [ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1
[ -z "${SMTP_USERNAME}" ] && echo "SMTP_USERNAME is not set" && exit 1
[ -z "${SMTP_PASSWORD}" ] && echo "SMTP_PASSWORD is not set" && exit 1
[ -z "${SERVER_HOSTNAME}" ] && echo "SERVER_HOSTNAME is not set" && exit 1 [ -z "${SERVER_HOSTNAME}" ] && echo "SERVER_HOSTNAME is not set" && exit 1
[ ! -z "${SMTP_USERNAME}" -a -z "${SMTP_PASSWORD}" ] && echo "SMTP_USERNAME is set but SMTP_PASSWORD is not set" && exit 1
SMTP_PORT="${SMTP_PORT:-587}" SMTP_PORT="${SMTP_PORT:-587}"
@@ -33,10 +32,15 @@ add_config_value "mydestination" 'localhost'
add_config_value "myorigin" '$mydomain' add_config_value "myorigin" '$mydomain'
add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}" add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}"
add_config_value "smtp_use_tls" "yes" add_config_value "smtp_use_tls" "yes"
add_config_value "smtp_sasl_auth_enable" "yes" if [ ! -z "${SMTP_USERNAME}" ]; then
add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd" add_config_value "smtp_sasl_auth_enable" "yes"
add_config_value "smtp_sasl_security_options" "noanonymous" add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd"
add_config_value "smtp_sasl_security_options" "noanonymous"
fi
add_config_value "always_add_missing_headers" "${ALWAYS_ADD_MISSING_HEADERS:-no}" add_config_value "always_add_missing_headers" "${ALWAYS_ADD_MISSING_HEADERS:-no}"
#Also use "native" option to allow looking up hosts added to /etc/hosts via
# docker options (issue #51)
add_config_value "smtp_host_lookup" "native,dns"
if [ "${SMTP_PORT}" = "465" ]; then if [ "${SMTP_PORT}" = "465" ]; then
add_config_value "smtp_tls_wrappermode" "yes" add_config_value "smtp_tls_wrappermode" "yes"
@@ -44,7 +48,7 @@ if [ "${SMTP_PORT}" = "465" ]; then
fi fi
# Create sasl_passwd file with auth credentials # Create sasl_passwd file with auth credentials
if [ ! -f /etc/postfix/sasl_passwd ]; then if [ ! -f /etc/postfix/sasl_passwd -a ! -z "${SMTP_USERNAME}" ]; then
grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1 grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "Adding SASL authentication configuration" echo "Adding SASL authentication configuration"