Skip to content

Commit c56ce80

Browse files
goruhaosterman
authored andcommitted
SMTP Relay Support with SASL Authentication (#1)
1 parent ac06527 commit c56ce80

13 files changed

Lines changed: 178 additions & 98 deletions

File tree

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Override for Makefile
2+
# Override for Makefile
3+
[{Makefile, makefile, GNUmakefile}]
4+
indent_style = tab
5+
indent_size = 4
6+
7+
[Makefile.*]
8+
indent_style = tab
9+
indent_size = 4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build-harness/
2+
.build-harness

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
sudo: required
2+
addons:
3+
apt:
4+
packages:
5+
- git
6+
- make
7+
- curl
8+
env:
9+
- DOCKER_IMAGE_NAME=cloudposse/postfix
10+
services:
11+
- docker
12+
install:
13+
- make init
14+
- make docker:login
15+
16+
script:
17+
- make docker:build
18+
19+
after_success:
20+
- make travis:docker-tag-and-push

Dockerfile

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
# Inspired by:
2+
# http://uname.pingveno.net/blog/index.php/post/2014/02/01/Configure-Postfix-as-STMP-standalone-single-domain-server-using-Unix-users-and-PAM-on-Debian
3+
#
4+
# Test with:
5+
# testsaslauthd -u postmaster -p password -f /var/spool/postfix/var/run/saslauthd/mux
6+
# perl -MMIME::Base64 -e 'print encode_base64("\000postmaster\000password")'
7+
# openssl s_client -starttls smtp -crlf -connect localhost:587
8+
# AUTH PLAIN AHBvc3RtYXN0ZXIAcGFzc3dvcmQ=
9+
110
FROM ubuntu:14.04
2-
MAINTAINER Alex Sanz <asans@evirtualpost.com>
11+
MAINTAINER Cloud Posse, LLC <hello@cloudposse.com>
312
ENV DEBIAN_FRONTEND noninteractive
413
ENV POSTMASTER_USER postmaster
514
ENV POSTMASTER_PASS password
@@ -25,18 +34,4 @@ RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup && \
2534
adduser --quiet --disabled-password -shell /bin/bash --home /home/$POSTMASTER_USER --gecos "Postmaster" $POSTMASTER_USER && \
2635
echo "$POSTMASTER_USER:$POSTMASTER_PASS" | chpasswd
2736

28-
# Inspired by:
29-
# http://uname.pingveno.net/blog/index.php/post/2014/02/01/Configure-Postfix-as-STMP-standalone-single-domain-server-using-Unix-users-and-PAM-on-Debian
30-
31-
ADD start /start
32-
ADD rsyslogd.conf /etc/rsyslog.d/stdout.conf
33-
ADD master.cf /etc/postfix/
34-
ADD pam.d/ /etc/pam.d/
35-
ADD saslauthd /etc/default/saslauthd
36-
ADD smtpd.conf /etc/postfix/sasl/smtpd.conf
37-
38-
# Test with: testsaslauthd -u postmaster -p password -f /var/spool/postfix/var/run/saslauthd/mux
39-
# perl -MMIME::Base64 -e 'print encode_base64("\000postmaster\000password")'
40-
# openssl s_client -starttls smtp -crlf -connect localhost:587
41-
# AUTH PLAIN AHBvc3RtYXN0ZXIAcGFzc3dvcmQ=
42-
37+
ADD rootfs /

LICENSE

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright (c) 2014, Alex Sanz
1+
Original work Copyright (c) 2014, Alex Sanz
2+
Modified work Copyright (c) 2014-2017, Cloud Posse, LLC
3+
24
All rights reserved.
35

46
Redistribution and use in source and binary forms, with or without
@@ -11,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
1113
this list of conditions and the following disclaimer in the documentation
1214
and/or other materials provided with the distribution.
1315

14-
* Neither the name of the {organization} nor the names of its
16+
* Neither the name of the Alex Sanz and Cloud Posse, LLC, nor the names of its
1517
contributors may be used to endorse or promote products derived from
1618
this software without specific prior written permission.
1719

@@ -25,4 +27,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2527
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2628
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2729
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(shell curl --silent -o .build-harness "https://raw.githubusercontent.com/cloudposse/build-harness/master/templates/Makefile.build-harness"; echo .build-harness)

README.md

Lines changed: 23 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,40 @@
1+
# postfix [![Travis](https://img.shields.io/travis/cloudposse/postfix.svg)]()
12

2-
postfix mail server with configurable hostname and trusted hosts and proper
3-
shutdown handling
3+
This is project implements as a docker container a postfix mail server. It supports a configurable hostname, trusted hosts, proper
4+
shutdown handling and mail relay (e.g. to mailgun).
45

5-
Notes
6-
===
6+
## Notes
77

88
By default, connected rfc1918 networks are detected and allowed. Local networks
99
(127.0.0.1, ::1) are also allowed.
1010

11-
Syslog
12-
===
11+
## Syslog
1312

1413
Rsyslog is started automatically and sends logs to stdout
1514

16-
Suggested Volumes
17-
===
15+
## Suggested Volumes
1816

1917
* `/var/spool/postfix` is the spool directory. Its also where postfix chroots to by default.
2018
* `/etc/postfix` is the configuation directory
2119

22-
Options
23-
===
20+
## Configuration
2421

2522
You can customize the image behavior using environmental variables or entrypoint
2623
arguments.
2724

28-
<table>
29-
<thead>
30-
<th>Enviromental Variable(s)</th>
31-
<th>Entrypoint Option</th>
32-
<th>Description</th>
33-
</thead>
34-
<tbody>
35-
<tr>
36-
<td>(use <code>--hostname</code>)</td>
37-
<td><code>--mail-name</code></td>
38-
<td>Mail name to use (appears in mail headers). Defaults to hostname</td>
39-
</tr>
40-
<tr>
41-
<td>RELAYHOST="[relay hostname]</td>
42-
<td><code>--relayhost []</code></td>
43-
<td>The host to relay mail to.</td>
44-
</tr>
45-
<tr>
46-
<td><code>TRUST="local"</code> or <code>TRUST_LOCAL="0"</code></td>
47-
<td><code>--trust-local</code></td>
48-
<td>Trust addresses on the lo interface. Enabled by default</td>
49-
</tr>
50-
<tr>
51-
<td><code>TRUST="connected-rfc1918"</code> or <code>TRUST_CONNECTED_RFC="1"</code></td>
52-
<td><code>--trust-connected-rfc1918</code></td>
53-
<td>Trust all locally connected rfc1918 subnets. Enabled by default</td>
54-
</tr>
55-
<tr>
56-
<td><code>TRUST="connected"</code> or <code>TRUST_CONNECTED="1"</td>
57-
<td><code>--trust-connected</code></td>
58-
<td>Trust all addresses connected (excluding IPv6 local-link addresses). Disabled by default</td>
59-
</tr>
60-
<tr>
61-
<td><code>TRUST="rfc1918"</code> or <code>TRUST_RFC1918="1"</td>
62-
<td><code>--trust-rfc1918</code></td>
63-
<td>Trust all rfc1918 address. Disabled by default</td>
64-
</tr>
65-
<tr>
66-
<td><code>TRUST_LLA="1"</code></td>
67-
<td><code>--trust-lla</code></td>
68-
<td>Trust the fe80::/64 IPv6 subnet. Disabled by default</td>
69-
</tr>
70-
<tr>
71-
<td><code>TRUST_SUBNETS="[space separated list of subnets]"</code></td>
72-
<td><code>--trust-subnet []</code></td>
73-
<td>Trust the specified subnet (IPv4 and IPv6 supported). Disabled by default</td>
74-
</tr>
75-
<tr>
76-
<td><code>TRUST_INTERFACES="[space separated list of interfaces]"</code></td>
77-
<td><code>--trust-interface []</code></td>
78-
<td>Trust all network address on the interface (excluding IPv6 LLA). Disabled by default</td>
79-
</tr>
80-
<tr>
81-
<td></td>
82-
<td><code>--skip-trust-</code>*</td>
83-
<td>Use with local, connected-rfc1918, connected, rfc1918, or lla to skip trusting it. Disabled by default</td>
84-
</tr>
85-
<tr>
86-
<td></td>
87-
<td><code>--skip-all</code></td>
88-
<td>Disable/reset all trusts. Disabled by default</td>
89-
</tr>
90-
</tbody>
91-
</table>
25+
26+
| Enviromental Variable(s) | Entrypoint Option | Description |
27+
|---------------------------------------------------------|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
28+
| (use --hostname) | --mail-name | Mail name to use (appears in mail headers). Defaults to hostname |
29+
| RELAYHOST="[relay hostname] | --relayhost [] | The host to relay mail to. |
30+
| TRUST="local" or TRUST_LOCAL="0" | --trust-local | Trust addresses on the lo interface. Enabled by default |
31+
| TRUST="connected-rfc1918" or TRUST_CONNECTED_RFC="1" | --trust-connected-rfc1918 | Trust all locally connected rfc1918 subnets. Enabled by default |
32+
| TRUST="connected" or TRUST_CONNECTED="1" | --trust-connected | Trust all addresses connected (excluding IPv6 local-link addresses). Disabled by default |
33+
| TRUST="rfc1918" or TRUST_RFC1918="1" | --trust-rfc1918 | Trust all rfc1918 address. Disabled by default |
34+
| TRUST_LLA="1" | --trust-lla | Trust the fe80::/64 IPv6 subnet. Disabled by default |
35+
| TRUST_SUBNETS="[space separated list of subnets]" | --trust-subnet [] | Trust the specified subnet (IPv4 and IPv6 supported). Disabled by default |
36+
| TRUST_INTERFACES="[space separated list of interfaces]" | --trust-interface [] | Trust all network address on the interface (excluding IPv6 LLA). Disabled by default |
37+
| | --skip-trust-* | `local`, `connected-rfc1918`, `connected`, `rfc1918`, or `lla` to skip trusting it. |
38+
| | --skip-all | Disable/reset all trusts. Disabled by default |
39+
40+
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)