Giter Club home page Giter Club logo

docker-simple-mail-forwarder's Introduction

Simple Mail Forwarder (SMF) Docker

Gitter layers Docker Pulls Docker Stars Docker Repository on Quay.io

dockeri.co

Simplest and Smallest Email Forward Service for Docker.

  1. Config by one-line
  2. Run as docker start
  3. Image Size 10MB

View on GitHub | View on Docker

Voice from Users

@Brian Christner : After testing a ton of different mail projects I finally discovered Simple Mail Forwarder (SMF) by Huan. This image is based on Alpine which is already a positive. It is super tiny and as the name suggests, easy to use. link

@kachkaev : really happy to discover it! link

@kiani: have a working mail server, seriously, it was that easy. link

@counterbeing: great image. Wonderfully easy interface, with all that i need. ๐Ÿ‘ link

@nelfer: Guess what? Your image already supports this! link

@Czocher: It's at least a timesaver if not a lifesaver. link

@StrangePeanut: I am so glad to have found SMF. Many thanks for this brilliant solution to email forwarding. link

What is Simple Mail Forwarder (SMF)?

If you have a domain name, only want to have one (or a few) email address(es) on this domain, and you want to forward all the emails to another email account - Simple Mail Forwarder (SMF) is exactly what you need. (with Docker)

Because of the above, this docker image was built for ultimate simplicity. I've owned many domains and needed email addresses for them (for fun and/or work). I hated configuring email servers. Some DNS providers provide free email forwarding services for their own domains, some do not. And almost all email forwarding services are NOT free. So I decided to make one myself (thanks docker).

Related Services

I was willing to pay $10/year, but the cheapest plan I could find was $9 per month. Having a $10 USD machine with unlimited e-mail & domains per month is an amazing idea! And of course you could also put other dockers on this machine. :-D

Quick-start (TL;DR)

Just set SMF_CONFIG and run:

export SMF_CONFIG='[email protected]:[email protected]:test'
docker run -e SMF_CONFIG -p 25:25 zixia/simple-mail-forwarder

Don't forget to modify the DNS MX record of your domain. (in this example, it's testo.com)

This will forward all emails received by [email protected] to [email protected].

If you want to forward all emails sent to domain testo.com to [email protected], set it like so:

export SMF_CONFIG='@testo.com:[email protected]'

See? There is nothing easier.

If you want to run it constanly in the background add -t -d --restart=always after run:

docker run -t -d --restart=always -e SMF_CONFIG -p 25:25 zixia/simple-mail-forwarder
  • -t: Allocate a pseudo-tty
  • -d: Detached Mode
  • --restart=always: Restart this container automatically

Otherwise, docker thinks that your applications stops and shutdown the container.

Quick Test

Tested by BATS(Bash Automated Testing System), a bash implementation of TAP(Test Anything Protol).

How to run:

$ docker run zixia/simple-mail-forwarder test
>> exec bats test
1..20
ok 1 confirm hostname pretend to work.
ok 2 confirm hwclock pretend to work.
ok 3 service postfix could start/stop right.
ok 4 SMF_CONFIG exist
ok 5 SMF_DOMAIN exist
ok 6 virtual maping source is set
ok 7 virtual maping data is set
ok 8 virtual maping db is set
ok 9 system hostname FQDN resolvable
ok 10 postfix myhostname FQDN & resolvable
ok 11 check other hostname setting
ok 12 confirm postfix is running
ok 13 confirm port 25 is open
ok 14 crond is running
ok 15 ESMTP STATTLS supported
ok 16 ESMTP AUTH supported
ok 17 ESMTP STARTTLS supported
ok 18 create user [email protected] by password test
ok 19 ESMTP AUTH by [email protected]/test
ok 20 ESMTP TLS AUTH by [email protected]/test

You are all set! :-]

Environment Variable and Default Values

SMF_CONFIG: MUST be defined. there's no default setting. (set me! I'm the only parameter you need to set~)

TZ : (Optional) set the timezone , IE EST5EDT or Europe/Rome

SMF_CONFIG Examples

Here's how to config the only required SMF_CONFIG environment parameter of SMF Docker:

1. Basic

Forward all emails received by [email protected] to [email protected]:

Forward all emails received by any email address in domain testo.com to [email protected]:

export SMF_CONFIG='@testo.com:[email protected]'

You could get the ESMTP AUTH password for you on your docker log. It's randomly generated if you do not provide one.

2. Advanced

Add ESMTP AUTH password:

export SMF_CONFIG='[email protected]:[email protected]:ThisIsPassword'

Password will be printed on the docker log.

3. Hardcore

Add as many email accounts as you want, with or without password. Seperated by semicolon or a new line:

export SMF_CONFIG='[email protected]:[email protected]:ThisIsPassword;[email protected]:[email protected]:AnotherPassword'

Tips: if you only provide the first password and leave the rest blank, then the passwords for all the rest accounts will be the same as the last password value you set. This is by design.

You can also forward all emails received by [email protected] to multiple destination addresses:

SMF_RELAYHOST Examples

Here's how to configure a relayhost/smarthost to use for forwarding mail.

Send all outgoing mail trough a smarthost on 192.168.1.2

export SMF_RELAYHOST='192.168.1.2'

SMF_RELAYAUTH Examples

If the SMF_RELAYHOST require authentication,

export SMF_RELAYAUTH='[email protected]:RelayHostPassword'

TLS (SSL) Certificates

SMF creates its own certificate and private key when it starts. This certificate is self signed, so some systems might give you a warning about the server not being trusted. If you have valid certificates for the domain name of the host, then you can use them and avoid the warning about not being trusted.

  1. First you need to prepare the certificate files. Copy your full chain certificate to a file named smtp.cert (or smtp.ec.cert if it contains a EC certificate). Then copy the private key to a file named smtp.key (or smtp.ec.key if it contains a EC key)

  2. Copy these files to a folder. For example: /data/certs/. This folder will be mounted as a volume in SMF

  3. When creating the container, add the -v (volume) parameter to mount it to the folder /etc/postfix/cert/ like so:

    docker run  -e SMF_CONFIG -p 25:25 -v /data/certs/:/etc/postfix/cert/ zixia/simple-mail-forwarder
  4. Your emails should now be forwarded with trusted encryption. You can use this tool to test it: http://checktls.com/

If you do not have a certificate and don't have the budget to afford one, you can use https://letsencrypt.org if you have shell access to the server (Note, SMF does not provide this service, yet). Letsencrypt allows you to create valid trusted certificates for a server, if the server responds to the domain you specify. In order to do this, you need to run the program from within the server and have administrator rights.

  1. First install letsencrypt. This might vary by distribution, but in Ubuntu it is like this:

    sudo apt-get install letsencrypt
  2. Stop any web server that might be using port 80 (Apache, nginx, etc)

  3. Determine all of the domains and subdomains that you want the certificate to cover, for example mydomain.com, www.mydomain.com, smtp.mydomain.com, etc. Remember to include the domain that SMF will respond to (as per MX record in DNS configuration of the domain)

  4. Execute the following command (you can add as many domains as you wish with the -d option. But remember, their DNS resolution must resolve to the server where letsencrypt is being executed)

    letsencrypt certonly --standalone -d yourdomain.com -d www.yourdomain.com -d mail.yourdomain.com
  5. Follow the prompts and if everything is successful you will get your certificates in a folder like /etc/letsencrypt/live/mydomain.com

  6. You can now use those certificates to make SMF TLS trusted.

This was a quick way of how to use letsencrypt. For a full tutorial based on your OS see: https://certbot.eff.org/

DKIM

SMF will generate private/public keypairs for $SMF_DOMAIN and for all source domains contained in SMF_CONFIG. All keys will be stored in /var/db/dkim/<domain.tld>/.

This will enable DKIM for multiple domains and test for their validity on SMF startup.

Public key must be set as TXT record in DNS under default._domainkey name. default._domainkey can be found in /var/db/dkim/<domain.tld>/default.txt.

It is highly advised to mount /var/db/dkim/ folder to host, so generated keypair would not get lost/regenerated:

docker run -e SMF_CONFIG -p 25:25 -v $(pwd)/dkim:/var/db/dkim/ zixia/simple-mail-forwarder

SMF allows using environment variables to change the size of the DKIM key:

  • SMF_DKIM_KEYSIZE will set the keysize of the generated DKIM key (setting opendkim-genkey -b $SMF_DKIM_KEYSIZE). Defaults to 2048.

Stripping sender details

SMF will strip the sender's IP, client, and user agent headers when the SMF_SENDERPRIVACY environment variable is defined.

Custom postfix configuration

SMF allows using environment variables to add or change lines to postfix main.cf and master.cf configuration files.

  • SMF_POSTFIXMAIN_* variables will edit postfix main.cf entries.

    • Format: SMF_POSTFIXMAIN_option_name=value
    • Example: SMF_POSTFIXMAIN_soft_bounce=yes will call postconf -e soft_bounce=yes and add the option.
  • SMF_POSTFIXMASTER_* variables will edit postfix master.cf.

    • Format: SMF_POSTFIXMASTER_service__name__type__parameter_name=value Please note the double underscore __ to differentiate service and type (which require a / as separation symbol) and the single underscore _ used only by parameter names.
    • Example: SMF_POSTFIXMASTER_submission__inet__smtpd__recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject will call postconf -P submission/inet/smtpd/recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject and add the option.

Logging

The default log configuration of postfix is sending all log entries to /dev/stdout. Because file logs are important in some cases, SMF allows overriding the default log configuration of postfix.

  • SMF_POSTFIXLOG will edit postfix logging configuration
    • Format: SMF_POSTFIXLOG=value
    • Example: SMF_POSTFIXLOG=/var/log/postfix.log will call postconf maillog_file="/var/log/postfix.log"

Attention: The logfile path must start with "/var".

When you wish to rotate logs, look at the postfix logrotate command in the official documentation.

Enable SRS (Sender Rewriting Scheme)

SRS is required if the sender uses SPF for verification. If SRS is not enabled, SPF verification will fail. (Additional Informations to SRS)

You can enable SRS by setting the environment variable SMF_SRS=true. This will start PostSRSd inside the container. The secret is automatically created and the domain is set to SMF_DOMAIN. Now you just need to set the following environment variables for Postfix:

SMF_POSTFIXMAIN_sender_canonical_maps=tcp:localhost:10001
SMF_POSTFIXMAIN_sender_canonical_classes=envelope_sender
SMF_POSTFIXMAIN_recipient_canonical_maps=tcp:localhost:10002
SMF_POSTFIXMAIN_recipient_canonical_classes=envelope_recipient,header_recipient

Helper Scripts

  1. Build from source.

    ./script/build.sh latest
  2. Run a self-test for SMF docker.

    ./script/run.sh latest test
  3. Get a shell inside SMF docker.

    ./script/devshell.sh latest

Manual Test

$ telnet 127.0.0.1 25
> 220 testo.com ESMTP
ehlo test.com
> 250-testo.com
> 250-STARTTLS
> 250-AUTH PLAIN LOGIN
auth plain
> 334
dGVzdGlAdGVzdG8uY29tAHRlc3RpQHRlc3RvLmNvbQB0ZXN0
> 235 2.7.0 Authentication successful
quit
> 221 2.0.0 Bye
> Connection closed by foreign host

P.S. The magic string dGVzdGlAdGVzdG8uY29tAHRlc3RpQHRlc3RvLmNvbQB0ZXN0 stands for [email protected]\[email protected]\0test in base64 encoding, required by AUTH PLAIN.

Useful article about SMTP Authentication: http://www.fehcom.de/qmail/smtpauth.html

Bug

Github Issue - https://github.com/huan/docker-simple-mail-forwarder/issues

Useful Articles

  1. How to use docker to forward emails sent to your domain to your email (works for Gmail)

Changelog

master

v1.4 (Mar 9, 2021)

  1. Update DockerHub README.md @thexperiments #94
  2. Allow for setting any Postfix variables in the config file (both main.cf and master.cf) @dgraziotin #93
  3. Strips sender details (IP, client, user agent) when sending @dgraziotin #91
  4. Adds DKIM support for multiple domains @dgraziotin #89
  5. DKIM support for multiple domains @dgraziotin #88
  6. Add DKIM support @petslane #83
  7. Use script to install s6 with right platforms (arm/x86) @huan #76

v1.3 (17 Sep 2020)

  1. Upgrade alpine docker base image to 3.12
  2. Fix timeout args breaking changes
  3. Fix etc and libexec path change for postfix

v1.1 (09 Jun 2019)

  1. Timezone support by @me1299 #56 #57
  2. EC key support by @Czocher #51
  3. Upgrade CircleCI from v1 to v2 @huan
  4. Fix typo in README @universeroc #47
  5. Update Base to Alpine 3.8 @riptidewave93 #43
  6. Update alpine:latest as base image @martijnrondeel #37

v1.0.0 (25 Jul 2017)

  • Release v1.0

v0.4.3 (14 Jul 2017)

  1. Add a note about running it in the background to prevent docker auto shutdown. by @delmicio #27
  2. Added smarthost support by @Duumke #22
  3. Added support for mynetworks by @SamMousa #20
  4. Allow own certificates by @nelfer #15
  5. Updated documentation for forward all emails @nelfer #14
  6. ARM version of armhf by @dimitrovs #12
  7. use SMF_DOMAIN env for certificate's CN by @bcardiff #11
  8. allow multiple forwards separated by | by @kminek #7
  9. Update docker-compose.yml to fix tutum tag by @vegasbrianc #4

v0.4.2 (25 Sep 2016)

  1. close issue #1
  2. increace message size limit from 10MB to 40MB
  3. fix domain name in scripts
  4. fix unit test fail error: do not upgrade alpine
  5. restore deploy button in readme: it is docker cloud now.(former tutum)

v0.4.0

  1. switch FROM image from alpine to sillelien/base-alpine
  2. manage postfix service by S6
  3. solve PID 1 Zombie Problem
  4. enhanced busybox shell
  5. NOT to use OpenRC(very buggy run inside docker container) any more!
  6. better ESMTP TLS AUTH test script
  7. docker image size: 10MB

v0.3.0 <- Don't use me, I'm BUGGY

  1. CI(continuous integration) supported by use CircleCI
  2. CD(continuous delivery) supported by use Tutum Button
  3. write better tests
  4. tune OpenRC inside alpine linux
  5. full description README
  6. docker image size: 7MB

v0.2.0 <- Don't use me, I'm BUGGY

  1. supported specify user password
  2. supported ESMTP TLS
  3. docker image size: 7MB

v0.1.0

  1. dockerized
  2. basic forward function
  3. self-testing
  4. docker image size: 6MB

Cloud Requirement

  • A Cloud Service that could host docker is required.

  • A Docker management platform is recommanded.

    • Docker Cloud(Former Tutum) Deploy to Docker Cloud
  • Docker is required.

    • Docker.com

CONTRIBUTORS

contributor contributor contributor contributor contributor contributor contributor contributor

Author

Profile of Huan LI (ๆŽๅ“ๆก“) on StackOverflow

MAINTAINERS

COPYRIGHT & LICENSE

  • Code & Docs ยฉ 2015 - now Huan LI [email protected]
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

docker-simple-mail-forwarder's People

Contributors

bcardiff avatar cenk1cenk2 avatar czocher avatar davidglezz avatar delmicio avatar dgraziotin avatar dimitrovs avatar haratosan avatar huan avatar jeffrey04 avatar kminek avatar kukulor avatar martijnrondeel avatar me1299 avatar nelfer avatar petslane avatar riptidewave93 avatar sammousa avatar steilerdev avatar tamaro-skaljic avatar universeroc avatar varunbatrait avatar vegasbrianc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-simple-mail-forwarder's Issues

need help : test 6,7,18+ failed, SYSTEM ERROR

base

  • my domain : charlie123.xyz
  • forward to : [email protected]
  • docker cmd
    docker run -t -d --restart=always -e SMF_CONFIG='@charlie123.xyz:[email protected]' -p 25:25 zixia/simple-mail-forwarder

full logs

>> Chdir to /app...
 ____  _                 _         __  __       _ _ 
/ ___|(_)_ __ ___  _ __ | | ___   |  \/  | __ _(_) |
\___ \| | '_ ` _ \| '_ \| |/ _ \  | |\/| |/ _` | | |
 ___) | | | | | | | |_) | |  __/  | |  | | (_| | | |
|____/|_|_| |_| |_| .__/|_|\___|  |_|  |_|\__,_|_|_|
                  |_|                               
  _____                                _           
 |  ___|__  _ ____      ____ _ _ __ __| | ___ _ __ 
 | |_ / _ \| '__\ \ /\ / / _` | '__/ _` |/ _ \ '__|
 |  _| (_) | |   \ V  V / (_| | | | (_| |  __/ |   
 |_|  \___/|_|    \_/\_/ \__,_|_|  \__,_|\___|_|   
                                                  

Source#dc1b99e Tue Oct 23 13:10:55 2018 +0000 * master
Built on Tue Oct 23 13:11:39 UTC 2018 by b6abe5993f7b

>> ENV SMF_DOMAIN not set.
>> ENV SMF_CONFIG found. value:[@charlie123.xyz:[email protected]]
>> ARGV arguments found. value:[start]
Generating a 2048 bit RSA private key
.............................+++++
....+++++
writing new private key to 'smtp.key'
-----
>> SMF_CONFIG found in ENV. use this settings for forward maps.
>> Setting password[ny5xv7th] for user @charlie123.xyz ...
postmap: warning: /etc/postfix/virtual.db: duplicate entry: "@charlie123.xyz"
>> Set hostname to charlie123.xyz
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/.
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/pid
postfix/postfix-script: starting the Postfix mail system
>> Start self-testing...
1..17
ok 1 SMF_CONFIG exist
ok 2 SMF_DOMAIN exist
ok 3 virtual maping source is set
ok 4 virtual maping data is set
ok 5 virtual maping db is set
not ok 6 system hostname FQDN resolvable
# (in test file test/simple-mail-forwarder.bats, line 48)
#   `[ $status = 0 ]' failed
not ok 7 postfix myhostname FQDN & resolvable
# (in test file test/simple-mail-forwarder.bats, line 58)
#   `[ $status = 0 ]' failed
ok 8 check other hostname setting
ok 9 confirm postfix is running
ok 10 confirm port 25 is open
ok 11 crond is running # skip skip this for 0.3.0 -> 0.4.0
ok 12 ESMTP STATTLS supported
ok 13 ESMTP AUTH supported
ok 14 ESMTP STARTTLS connect ok
ok 15 create user [email protected] by password test
ok 16 ESMTP AUTH by [email protected]/test
ok 17 ESMTP TLS AUTH by [email protected]/test
>> Test FAILED!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!
>> But I'll pretend to run... good luck! :P


>> CONGRATULATIONS! System is UP and You are SET!
>> Powered by SMF - a Simple Mail Forwarder
>> View in DockerHub: https://hub.docker.com/r/zixia/simple-mail-forwarder


>> Init System for Servicing...
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[2019-04-25T09:25:12.682064] WARNING: Configuration file format is too old, syslog-ng is running in compatibility mode. Please update it to use the syslog-ng 3.13 format at your time of convenience. To upgrade the configuration, please review the warnings about incompatible changes printed by syslog-ng, and once completed change the @version header at the top of the configuration file.;
[services.d] done.
postfix/postfix-script: stopping the Postfix mail system
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/.
postfix/postfix-script: warning: not owned by root: /var/spool/postfix/pid

DKIM

It would be great to have DKIM support; getting messages signed is a requirement for most outgoing mail nowadays.

SPF Records

Any plans to add support for SPF Records?

A newbie question about mx records / mail not forwarded to gmail

Say this docker image is hosted at mail.htko.ca and my forwarded email is [email protected], is this a valid mx record? I'm completely new at this but I'd like to learn if possible. I'm hosting on digitalocean and the A record for mail.htko.ca is already set up to point at this docker server's ip. If this is inappropriate it's okay to close the issue!

Type Hostname Value Priority TTL
MX @ mail.htko.ca. 1 1800

Partial Log:

DNS : Starting monitoring loop
Jan 28 01:05:36 0928512d09b4 mail.info postfix/smtpd[2498]: connect from mail-ot0-f181.google.com[74.125.82.181]
Jan 28 01:05:36 0928512d09b4 mail.info postfix/smtpd[2498]: 63B69E16B5: client=mail-ot0-f181.google.com[74.125.82.181]
Jan 28 01:05:36 0928512d09b4 mail.info postfix/cleanup[2503]: 63B69E16B5: message-id=<CAN5vAZbZ7r0uqjH1T2YyWJHNF1CJqAWzwGhaOU11KJOgkXxUxw@mail.gmail.com>
Jan 28 01:05:36 0928512d09b4 mail.info postfix/qmgr[2448]: 63B69E16B5: from=<[email protected]>, size=2415, nrcpt=1 (queue active)
Jan 28 01:05:36 0928512d09b4 mail.info postfix/smtpd[2498]: disconnect from mail-ot0-f181.google.com[74.125.82.181] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Jan 28 01:05:36 0928512d09b4 mail.info postfix/smtp[2504]: 63B69E16B5: to=<[email protected]>, orig_to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.192.26]:25, delay=0.47, delays=0.11/0.01/0.2/0.15, dsn=2.0.0, status=sent (250 2.0.0 OK 1485565536 a79si4762390qkj.2
Jan 28 01:05:36 0928512d09b4 mail.info postfix/qmgr[2448]: 63B69E16B5: removed
Jan 28 01:08:56 0928512d09b4 mail.info postfix/anvil[2501]: statistics: max connection rate 1/60s for (smtp:74.125.82.181) at Jan 28 01:05:36
Jan 28 01:08:56 0928512d09b4 mail.info postfix/anvil[2501]: statistics: max connection count 1 for (smtp:74.125.82.181) at Jan 28 01:05:36
Jan 28 01:08:56 0928512d09b4 mail.info postfix/anvil[2501]: statistics: max newtls rate 1/60s for (smtp:74.125.82.181) at Jan 28 01:05:36
Jan 28 01:08:56 0928512d09b4 mail.info postfix/anvil[2501]: statistics: max cache size 1 at Jan 28 01:05:36

I seem to be missing something, I am not getting any mail at [email protected] when I send things to [email protected]

Base image

Is the unofficial base image still needed?

It would be preferable to use the official alpine image as base.
Also, there are packages in alpine that offer s6, so there is no need to download it manually as the current base image does.

Side note: https://github.com/sillelien/base-alpine hasn't been updated in over a year.

DKIM support for multiple domains

As discussed in #83, SMF needs a way to handle DKIM for multiple domains.

In particular, it should gracefully handle the domain defined in $SMF_DOMAIN for backward compatibility (going back to single DKIM), create DKIM public/private keypairs to be used for all source domains in $SMF_CONFIG, adapt /var/db/dkim/ to a per-domain path style, and change /etc/opendkim/opendkim.conf to use KeyTable, SigningTable, ExternalIgnoreList, and InternalHosts.

Finally, SMF should check validity of all DKIM keys on startup.

This is underway.

use as SMTP server?

Just want to check if I read correctly, besides forwarding mail, does the container also act as a SMTP server where I can setup my client to use the password in SMF_CONFIG ?

Couldn't really get mail being forwarded after the setup however, not sure if I doing this correctly. The internal test cases all passes, but mail doesn't get forwarded / sent.

this is my docker-compose snippet

    mail:
        image: "zixia/simple-mail-forwarder"
        ports:
            - "587:25"
        restart: always
        tty: true
        environment:
            SMF_CONFIG: "$origin_email:$dest_email:randompassword!"
            SMF_DOMAIN: coolsilon.com
            TZ: "Asia/Kuala_Lumpur"
        volumes:
            - "/var/lib/docker-files/letsencrypt/:/etc/postfix/cert/"

and the respective DNS

root@doraemon:/var/lib/docker-files/coolsilon# dig +short MX coolsilon.com
10 mail.coolsilon.com.
root@doraemon:/var/lib/docker-files/coolsilon# dig +short CNAME mail.coolsilon.com
coolsilon.com.
root@doraemon:/var/lib/docker-files/coolsilon# dig +short TXT coolsilon.com
"v=spf1 mx ~all"

I found a script online to send mail through SMTP, while the script executed without an error returned, but I don't see the test mail in my mailbox.

# Import smtplib for the actual sending function
import smtplib
import ssl

# Import the email modules we'll need
from email.mime.text import MIMEText

import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
msg = MIMEText("Test")

me = "[email protected]"
you = "[email protected]"

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'Test'
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server, but don't include the
# envelope header.
with smtplib.SMTP("coolsilon.com", 587) as server:
    print('login', server.login(me, '***!'))
    print('send', server.sendmail(me, [you], msg.as_string()))
    server.quit()

Choosing timezone for container

Time in container is different than on the system - it's about 2 Hours away from correct (I'm using UTC time on the machine). Is there a way how to set time with env variables ?

Postfix logs

Where I could find Postfix logs? I tried to find the path but I couldn't. I think it is a good idea to update README with this info.

smf treat the forward domain as local destination

Some company don't provide smtp relay service at all. I have a case that they use microsoft exchange, and disabled smtp service for users. so users only could use IMAP, or ActiveSync on mobile.

If I need a relay smtp for my email address(for gmail "send mail as" required). Use SMF and set a forward config, it works. I could use SMF as my smtp relay to send emails.

Everything is so fa so good, except one BUG here: if I send mail to the other user of this domain, then I will got a "no such user" error.

This is because SMF thought itself is managing the virtual domain of my mail address. and obviously, that domain has only one user: me.

This should be fixed. maybe by add a cacht-all rule to virtual config, and forward all the mail with unknown user, to the right MX of email address domain.

TBD.

Migrate to CircleCI 2.0.

Projects currently running on CircleCI 1.0 are no longer supported. Please migrate to CircleCI 2.0.

Support for ECC keys

Hello,
First of all thanks for all your hard work on the project, it's at least a time saver if not a lifesaver.
My problem is that the only SSL keys I have for my domain are not RSA keys but ECC keys. From what I know postfix support ECC keys by two config options:

smtpd_tls_eckey_file = smtpd-key-ecdsa.key
smtpd_tls_eccert_file = smtpd-cert-ecdsa.cert

The problem is, from what I see the main.dist.cf file accepts only RSA keys with the smtpd_tls_key_file and smtpd_tls_cert_file directive.

Is there any possibility for ECC key support to be added to the container too?

Unit testing is keeping failing...

I'm getting many headaches to looking into it and trying to fix it... :(

@test "ESMTP TLS AUTH by [email protected]/test" {
#
# # perl -MMIME::Base64 -e 'print encode_base64("testi\@testo.com\0testi\@testo.com\0test");'
# dGVzdGlAdGVzdG8uY29tAHRlc3RpQHRlc3RvLmNvbQB0ZXN0
#
FIFO_SSL_I=/tmp/ssli.$$
FIFO_SSL_O=/tmp/sslo.$$
mkfifo $FIFO_SSL_{I,O}
0<$FIFO_SSL_I &>$FIFO_SSL_O \
timeout -t 7 -s TERM \
openssl s_client -starttls smtp -crlf -connect 127.0.0.1:25 &
exec {FD_I}> $FIFO_SSL_I
exec {FD_O}< $FIFO_SSL_O
ret=1
while read line; do
line=$(sed 's/\r$//'<<<$line)
if [[ $line =~ 'CONNECTED' ]]; then
>& $FD_I echo 'AUTH PLAIN dGVzdGlAdGVzdG8uY29tAHRlc3RpQHRlc3RvLmNvbQB0ZXN0'
elif [[ $line =~ '235 2.7.0 Authentication successful' ]]; then
>& $FD_I echo 'QUIT'
exec {FD_I}>&-
ret=0
elif [[ $line =~ '503 5.5.1 Error: already authenticated' ]]; then
>& $FD_I echo 'QUIT'
exec {FD_I}>&-
ret=0
fi
done <& $FD_O
unlink $FIFO_SSL_I
unlink $FIFO_SSL_O
[ $ret = 0 ]
}

There are no changes at all in the past dozens of weeks, what's wrong?

See: https://circleci.com/gh/huan/docker-simple-mail-forwarder/20

Issue when using volume mounts.

When mounting a volume on /etc the container won't launch:

postconf: fatal: open /etc/postfix/main.cf

Shouldn't these be copied into the volume by the scripts on launch?

SMF_CONFIG not found

Hi,

I am trying to run SMF. But it seems that setting the configuration does not work. Is there another way to set the configuration than exporting the variable?
I tried it on Ubuntu 14.04 and 15.10 with docker 1.9.1.

# export SMF_CONFIG='[email protected]:[email protected]'
# docker run -p 25:25 zixia/simple-mail-forwarder
>> Chdir to /app...
 ____  _                 _         __  __       _ _ 
/ ___|(_)_ __ ___  _ __ | | ___   |  \/  | __ _(_) |
\___ \| | '_ ` _ \| '_ \| |/ _ \  | |\/| |/ _` | | |
 ___) | | | | | | | |_) | |  __/  | |  | | (_| | | |
|____/|_|_| |_| |_| .__/|_|\___|  |_|  |_|\__,_|_|_|
                  |_|                               
  _____                                _           
 |  ___|__  _ ____      ____ _ _ __ __| | ___ _ __ 
 | |_ / _ \| '__\ \ /\ / / _` | '__/ _` |/ _ \ '__|
 |  _| (_) | |   \ V  V / (_| | | | (_| |  __/ |   
 |_|  \___/|_|    \_/\_/ \__,_|_|  \__,_|\___|_|   


Source#3ed301b Sat Dec 19 13:00:32 2015 +0000 * master
Built on Sat Dec 19 13:00:49 UTC 2015 by b700c9167997

>> ENV SMF_DOMAIN not set.
>> END SMF_CONFIG not set.
>> ARGV arguments found. value:[start]
Generating a 2048 bit RSA private key
................+++
..+++
writing new private key to 'smtp.key'
-----
>> SMF_CONFIG not found. format: [email protected]:[email protected];...
>> I don't know how to do. So I quit.

Relayhost config

Hi,

This is a really nice piece of work.
The only thing I'm missing is to be able to select a relay host.
Is it possible to have this into the system like: export SMF_RELAYHOST='@Domain:'

That would make this great as I have to use a relay host to make the mail reach the correct mailserver.

Thank you for your time.

Duumke

SYSTEM ERROR

When I start the SMF, I see the following in the log:

2017-04-25 10:04:12 backend smf ok 16 ESMTP AUTH by [email protected]/test
2017-04-25 10:04:12 backend smf ok 17 ESMTP TLS AUTH by [email protected]/test
2017-04-25 10:04:12 backend smf >> Test FAILED!
2017-04-25 10:04:12 backend smf >> !!!!!!!!!!!!!!!!!!!! SYSTEM ERROR !!!!!!!!!!!!!!!!!!!!

Is there a way to know better was has failed?

Waiting for IP address x.x.x.x to be reachable, then fail

Hi! I used this image before and it was working great. I moved to a Rancher 2 (Kubernetes) installation and I'm trying to figure out why it's not working anymore. I correctly exposed the port 25 to my host as usual, the full log is here (relevant part at the bottom):

Logs

>> Chdir to /app...

 ____  _                 _         __  __       _ _

/ ___|(_)_ __ ___  _ __ | | ___   |  \/  | __ _(_) |

\___ \| | '_ ` _ \| '_ \| |/ _ \  | |\/| |/ _` | | |

 ___) | | | | | | | |_) | |  __/  | |  | | (_| | | |

|____/|_|_| |_| |_| .__/|_|\___|  |_|  |_|\__,_|_|_|

                  |_|

  _____                                _

 |  ___|__  _ ____      ____ _ _ __ __| | ___ _ __

 | |_ / _ \| '__\ \ /\ / / _` | '__/ _` |/ _ \ '__|

 |  _| (_) | |   \ V  V / (_| | | | (_| |  __/ |

 |_|  \___/|_|    \_/\_/ \__,_|_|  \__,_|\___|_|

Source#2e175b1 Tue Jul 24 14:26:06 2018 +0000 * master

Built on Tue Jul 24 14:26:32 UTC 2018 by b700c9167997

>> ENV SMF_DOMAIN not set.

>> ENV SMF_CONFIG found. value:[@mydomain.com:[email protected]]

>> ARGV arguments found. value:[start]

Generating a 2048 bit RSA private key

......................................................+++

..........................................+++

writing new private key to 'smtp.key'

-----

>> SMF_CONFIG found in ENV. use this settings for forward maps.

>> Setting password[mjfocjp4] for user @mydomain.com ...

postmap: warning: /etc/postfix/virtual.db: duplicate entry: "@mydomain.com"

Error: could not find any address for the name: `wimi.36c33f49.svc.dockerapp.io'

>> Set hostname to mydomain.com

postfix/postfix-script: warning: not owned by root: /var/spool/postfix/.

postfix/postfix-script: warning: not owned by root: /var/spool/postfix/pid

postfix/postfix-script: starting the Postfix mail system

>> Start self-testing...

1..17

ok 1 SMF_CONFIG exist

ok 2 SMF_DOMAIN exist

ok 3 virtual maping source is set

ok 4 virtual maping data is set

ok 5 virtual maping db is set

ok 6 system hostname FQDN resolvable

ok 7 postfix myhostname FQDN & resolvable

ok 8 check other hostname setting

ok 9 confirm postfix is running

ok 10 confirm port 25 is open

ok 11 # skip (skip this for 0.3.0 -> 0.4.0) crond is running

ok 12 ESMTP STATTLS supported

ok 13 ESMTP AUTH supported

ok 14 ESMTP STARTTLS connect ok

ok 15 create user [email protected] by password test

ok 16 ESMTP AUTH by [email protected]/test

ok 17 ESMTP TLS AUTH by [email protected]/test

>> Test PASSED

>> CONGRATULATIONS! System is UP and You are SET!

>> Powered by SMF - a Simple Mail Forwarder

>> View in DockerHub: https://hub.docker.com/r/zixia/simple-mail-forwarder

>> Init System for Servicing...

[fix-attrs.d] applying owners & permissions fixes...

[fix-attrs.d] 00-runscripts: applying...

[fix-attrs.d] 00-runscripts: exited 0.

[fix-attrs.d] done.

[cont-init.d] executing container initialization scripts...

[cont-init.d] dns_init.sh: executing...

DNS : Initial Setup

DNS STEP 1 : Creating the dnsmasq-resolv.conf

DNS : Contents of dnsmasq-resolv.conf

-------------------

nameserver 213.136.95.10

nameserver 213.136.95.11

nameserver 2a02:c207::1:53

DNS STEP 2 : Adding the linked services

Waiting for linked IP address 10.43.0.1 to be reachable

Waiting for linked IP address 10.43.0.1 to be reachable

Waiting for linked IP address 10.43.0.1 to be reachable

Waiting for linked IP address 10.43.0.1 to be reachable

DNS : Timed out setting up DNS.

[cont-finish.d] executing container finish scripts...

[cont-finish.d] done.

[s6-finish] syncing disks.

[s6-finish] sending all processes the TERM signal.

[s6-finish] sending all processes the KILL signal and exiting.

Apparently it's trying to resolve 10.43.0.1 which is not even the container IP. Any ideas?

Thank you!

Getting timeouts when the email is forwarded so no email delivered

Hi, not sure if this is a bug or not:

Aug 12 22:37:54 5de1a1801612 mail.info postfix/smtpd[2857]: connect from mail-yw1-f44.google.com[209.85.161.44]
Aug 12 22:37:55 5de1a1801612 mail.info postfix/smtpd[2857]: 58E4E422EB: client=mail-yw1-f44.google.com[209.85.161.44]
Aug 12 22:37:55 5de1a1801612 mail.info postfix/cleanup[2860]: 58E4E422EB: message-id=CAO6f_5ZorXvvxWC5e6DppZMwDVsLABanjb=xpc3X9AkeW_J=gw@mail.gmail.com
Aug 12 22:37:55 5de1a1801612 mail.info postfix/qmgr[2673]: 58E4E422EB: from=, size=2678, nrcpt=1 (queue active)
Aug 12 22:37:55 5de1a1801612 mail.info postfix/smtpd[2857]: disconnect from mail-yw1-f44.google.com[209.85.161.44] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Aug 12 22:38:25 5de1a1801612 mail.info postfix/smtp[2861]: connect to ASPMX.L.GOOGLE.COM[64.233.188.27]:25: Operation timed out

Building for ARM

I switched the Dockerfile to build from this image: FROM armbuild/alpine and I added the openssl package. It builds fine and appears to start, but it can't find the /init file. Where is this /init file supposed to come from?

ESMTP AUTH: Possible backdoor/hole that can lead to abuse

Hello,

I was recently testing this, trying to use my own password for an email alias (from gmail) and it was not working (I'll keep investigating that issue) and then I noticed in the logs there's an initial self-test and saw this:

ok 15 create user [email protected] by password test
ok 16 ESMTP AUTH by [email protected]/test

And so I tried from gmail to use those credentials and lo and behold: I was able to use the server to send emails on my behalf with an alias. Using the credentials created during self-test. In other words, anyone can exploit this and send emails as it was coming from the aliased addresses

Granted, I'm not in the latest, so not sure if the latest version "removes" this account after the test.

Is there a reason of concern for this? From the SMTP connection, nothing reveals the server is running this software, so in order to exploit it, someone has to know that the server is running SMF

Update arm32v7, timed out connection

Can you create an image with arm32v7 support? I need to run this on raspberry pi 3, but the architecture is not supported, I got the following error: standard_init_linux.go:207: exec user process caused "exec format error"

Hard coded urls

What does this code do in build.sh?

RE='[0-9]+\s+IN\s+A\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
[[ `drill DockerMailForwarder.Builder.\`hostname\` @wimi.36c33f49.svc.dockerapp.io` =~ $RE ]] && {
    DMF_BUILD_IP="${BASH_REMATCH[1]}"
}

Encryption during forwarding

Hi again Zhuohuan,

A little possible issue here. Could you please document on how encryption can be done during forwarding? I've got this message from google after getting a redirected email.

screen shot 2016-07-19 at 00 33 48

Learn more points here.

No worries if this is not possible - I personally don't needed encryption. Just curious about how things work โ€“ this may also help other potential users :โ€“)

Tag latest

Hi Zhuohuan and thank you for this image โ€“ really happy to discover it!
I prefer specifying exact version in my docker-compose.yml and it seems that 0.4.0 tag is outdated. Could you please create a new fixed tag for what is now latest?

Cheers!

No longer see the mail log

Hi Huan,

I can no longer see the incoming/outgoing mail log in the docker logs since using the latest version 1.1.

Is this so by design?

connect to gmail-smtp-in.l.google.com[74.125.133.26]:25: Operation timed out

3:03:59 c49364445807 mail.info postfix/smtpd[2468]: connect from unknown[10.1.93.1]

3:03:59 c49364445807 mail.info postfix/smtpd[2468]: B46DF109548: client=unknown[10.1.93.1]

3:03:59 c49364445807 mail.info postfix/cleanup[2473]: B46DF109548: message-id=<CAEsnweGR9f+g5vstm+kR+gBD=gozrZyMcZKZs3UVhki-aoskzg@mail.gmail.com>

3:03:59 c49364445807 mail.info postfix/qmgr[2453]: B46DF109548: from=<{my address}@googlemail.com>, size=3195, nrcpt=1 (queue active)

3:03:59 c49364445807 mail.info postfix/smtpd[2468]: disconnect from unknown[10.1.93.1] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7

3:04:29 c49364445807 mail.info postfix/smtp[2474]: connect to gmail-smtp-in.l.google.com[74.125.133.26]:25: Operation timed out

3:04:59 c49364445807 mail.info postfix/smtp[2474]: connect to alt1.gmail-smtp-in.l.google.com[74.125.205.27]:25: Operation timed out

3:05:29 c49364445807 mail.info postfix/smtp[2474]: connect to alt2.gmail-smtp-in.l.google.com[74.125.130.27]:25: Operation timed out

3:05:59 c49364445807 mail.info postfix/smtp[2474]: connect to alt3.gmail-smtp-in.l.google.com[108.177.97.27]:25: Operation timed out

3:06:12 c49364445807 mail.warn postfix/smtpd[2468]: warning: unknown[10.1.93.1]: SASL plain authentication failed: bad protocol / cancel

3:06:30 c49364445807 mail.info postfix/smtp[2474]: connect to alt4.gmail-smtp-in.l.google.com[74.125.28.27]:25: Operation timed out

3:06:30 c49364445807 mail.info postfix/smtp[2474]: B46DF109548: to=<{my address}@gmail.com>, orig_to=<[email protected]>, relay=none, delay=150, delays=0.12/0.02/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[74.125.28.27]:25: Operation timed out

3:06:30 c49364445807 mail.warn postfix/smtpd[2468]: warning: SASL authentication failure: Couldn't find mech none

3:06:30 c49364445807 mail.warn postfix/smtpd[2468]: warning: unknown[10.1.93.1]: SASL none authentication failed: no mechanism available

Timezone support

It would be nice to set the correct timezone for the docker container. Now my log files are not in sync with the actual time making it harder to debug.

Time zone data package tzdata could be included in the container.

Block IP from brute force attached on mail forwarder using CIDR

Hi,

One of my dockers based on your great work is being attacked by some people trying to brute force it. The IPs seem limited to two or three, so it should be easy to block them. An article on how to do this is here: https://ethitter.com/2016/03/blocking-sender-ips-in-postfix/

Example of the logs where people try to login:
Jan 24 09:42:36 cafff8e519dd postfix/smtpd[25002]: connect from unknown[212.70.149.85]
Jan 24 09:42:37 cafff8e519dd postfix/smtpd[24875]: warning: unknown[212.70.149.54]: SASL LOGIN authentication failed: authentication failure
Jan 24 09:42:38 cafff8e519dd postfix/smtpd[24875]: disconnect from unknown[212.70.149.54] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jan 24 09:42:45 cafff8e519dd postfix/smtpd[25002]: warning: unknown[212.70.149.85]: SASL LOGIN authentication failed: authentication failure
Jan 24 09:42:47 cafff8e519dd postfix/smtpd[25002]: disconnect from unknown[212.70.149.85] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jan 24 09:42:51 cafff8e519dd postfix/smtpd[24875]: connect from unknown[212.70.149.54]
Jan 24 09:42:57 cafff8e519dd postfix/smtpd[25002]: connect from unknown[212.70.149.85]

However, it seems the postmap in your docker is not able to handle cidr, as I get this error message below:
bash-5.0# postmap cidr:client_checks
postmap: fatal: unsupported dictionary type: cidr. Is the postfix-cidr package installed?
bash-5.0#

Is it possible to upgrade the postfix package to one that includes the cidr capability?
Since my 'attackers' seem limited, I do not feel I need to use other tools to block them.

Thanks,
Mike

Exec /init: No such file or directory

Hi,

Im struggling to get the docker image to run, container stops shortly after start with finally message

Init System for Servicing...
/entrypoint.sh: line 310: /init: No such file or directory

Reload SMF configuration by run `docker-compose up -d`

Hi, I didn't find any mention in the docs about having multiple domain names.
Is this supported in any way?
I tried it and it looks like it is only forwarding emails from the first domain.
Emails sent to the second domain fail with:

NOQUEUE: reject: RCPT from mail-vs1-f42.google.com[209.85.217.42]: 454 4.7.1 <[email protected]>: Relay access denied;
disconnect from mail-vs1-f42.google.com[209.85.217.42] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7

Help, not working, not that simple

Hello, I'm trying yo make this work and this is what I've done so far.

  • Docker 1.12.4 on 16.04

image

Here is the log that the console is showing:

DNS : initial work complete
[cont-init.d] dns_init.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Feb 9 19:15:45 fbdeed7e9cc8 syslog.info syslogd started: BusyBox v1.23.2
DNS : Waiting for dnsmasq
DNS : Starting monitoring loop
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: started, version 2.72 cachesize 150
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: started, version 2.72 cachesize 150
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: reading /etc/dnsmasq-resolv.conf
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: reading /etc/dnsmasq-resolv.conf
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: using nameserver 8.8.8.8#53
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: using nameserver 8.8.8.8#53
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: using nameserver 8.8.4.4#53
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: using nameserver 8.8.4.4#53
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: read /etc/hosts - 8 addresses
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: read /etc/hosts - 8 addresses
Feb 9 19:15:45 fbdeed7e9cc8 user.notice root: dnsmasq: read /etc/hosts.links - 0 addresses
Feb 9 19:15:45 fbdeed7e9cc8 local0.info dnsmasq[2371]: read /etc/hosts.links - 0 addresses
postfix/postfix-script: stopping the Postfix mail system
Feb 9 19:15:45 fbdeed7e9cc8 mail.info postfix/postfix-script[2385]: stopping the Postfix mail system
Feb 9 19:15:45 fbdeed7e9cc8 mail.info postfix/master[99]: terminating on signal 15
Feb 9 19:15:45 fbdeed7e9cc8 mail.info postfix/master[2452]: daemon started -- version 3.0.1, configuration /etc/postfix

Should this be working?
docker run -tde SMF_CONFIG="$SMF_CONFIG" -p 25:25 zixia/simple-mail-forwarder

bad interpreter: No such file or directory

In both the 1.3 and 1.2 docker images, I receive the following errors:

/entrypoint.sh: /init: /bin/execlineb: bad interpreter: No such file or directory
/entrypoint.sh: line 321: /init: No error information

Running 1.1 doesn't have the issue. Were there any config changes/additions/etc... that maybe I missed?

Full log:

>> Chdir to /app...
 ____  _                 _         __  __       _ _
/ ___|(_)_ __ ___  _ __ | | ___   |  \/  | __ _(_) |
\___ \| | '_ ` _ \| '_ \| |/ _ \  | |\/| |/ _` | | |
 ___) | | | | | | | |_) | |  __/  | |  | | (_| | | |
|____/|_|_| |_| |_| .__/|_|\___|  |_|  |_|\__,_|_|_|
                  |_|
  _____                                _
 |  ___|__  _ ____      ____ _ _ __ __| | ___ _ __
 | |_ / _ \| '__\ \ /\ / / _` | '__/ _` |/ _ \ '__|
 |  _| (_) | |   \ V  V / (_| | | | (_| |  __/ |
 |_|  \___/|_|    \_/\_/ \__,_|_|  \__,_|\___|_|


Source#2bacd4b Thu Oct 15 00:02:48 2020 +0800 * master
Built on Fri Sep 11 18:33:58 UTC 2020 by buildkitsandbox

>> END SMF_DOMAIN found. value:[*****.*****.***]
>> ENV SMF_CONFIG found. value:[@*****.***:*****@*****.***]
>> ARGV arguments found. value:[start]
>> SMF_CONFIG found in ENV. use this settings for forward maps.
>> Setting password[********] for user @*****.*** ...
postmap: warning: /etc/postfix/virtual.db: duplicate entry: "@*****.***"
>> Set hostname to *****.*****.***
>> Start self-testing...
1..17
ok 1 SMF_CONFIG exist
ok 2 SMF_DOMAIN exist
ok 3 virtual maping source is set
ok 4 virtual maping data is set
ok 5 virtual maping db is set
ok 6 system hostname FQDN resolvable
ok 7 postfix myhostname FQDN & resolvable
ok 8 check other hostname setting
ok 9 confirm postfix is running
ok 10 confirm port 25 is open
ok 11 crond is running # skip skip this for 0.3.0 -> 0.4.0
ok 12 ESMTP STATTLS supported
ok 13 ESMTP AUTH supported
ok 14 ESMTP STARTTLS connect ok
ok 15 create user [email protected] by password test
ok 16 ESMTP AUTH by [email protected]/test
ok 17 ESMTP TLS AUTH by [email protected]/test
>> Test PASSED


>> CONGRATULATIONS! System is UP and You are SET!
>> Powered by SMF - a Simple Mail Forwarder
>> View in DockerHub: https://hub.docker.com/r/zixia/simple-mail-forwarder


>> Init System for Servicing...
/entrypoint.sh: /init: /bin/execlineb: bad interpreter: No such file or directory
/entrypoint.sh: line 321: /init: No error information

docker-compose

version: '3'
services:

  mail:
    container_name: mail
    restart: always
    image: zixia/simple-mail-forwarder:latest
    ports:
      - "25:25"
    volumes:
      - /home/user/mail/certs:/etc/postfix/cert
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro

    environment:
      SMF_CONFIG: "@*****.***:*****@*****.***"
      SMF_DOMAIN: *****.*****.***
      VIRTUAL_HOST: *****.*****.***
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.tcp.routers.mail.entrypoints=mail"
      - "traefik.tcp.routers.mail.service=mail"
      - "traefik.tcp.routers.mail.rule=HostSNI(`*****.*****.***`)"
      - "traefik.tcp.routers.mail.tls=true"
      - "traefik.tcp.routers.mail.tls.certresolver=le"
      - "traefik.tcp.services.mail.loadbalancer.server.port=25"
networks:
  proxy:
    external: true

Tag new release.

The latest tag is quite old. We could use a new tagged version!

Allow for setting any Postfix variables in the config file

Stolen from wader/postfix-relay, I propose to add the following line to your entrypoint.sh:

for e in ${!POSTFIX_*} ; do postconf -e "${e:8}=${!e}" ; done

This allows for setting up postfix in a Docker swarm / compose, without having to mount a whole configfile. Usage:

  mail_relay:
    image: zixia/simple-mail-forwarder:1.1
    networks:
      - traefik-public
      - default
    deploy:
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.constraint-label=traefik-public
        - traefik.tcp.routers.mail_relay.rule=HostSNI(`*`)
        - traefik.tcp.routers.mail_relay.entrypoints=smtp
        - traefik.tcp.routers.mail_relay.service=mail_relay
        - traefik.tcp.services.mail_relay.loadbalancer.server.port=25
    environment:
      - SMF_DOMAIN=domain1.com
      - |
        SMF_CONFIG=
        [email protected]:[email protected];
        [email protected]:[email protected];
      - POSTFIX_myhostname=smtp.domain1.com
      - POSTFIX_relay_domains="domain1.com domain2.com"
      - POSTFIX_smtpd_recipient_restrictions=permit_mynetworks, permit_sasl_authenticated

(note the last three lines)

Wildcard forward?

Hi,
My current DNS provider has a feature that they can forward *@mydomain.com to an email.
Is this possible with your program?
The reason why I need this is because I might give email addresses on the fly. For example, if I'm filing up a survey, I'll put something like <myname>.<surveycompany>@mydomain.com and sure enough, I'll get emails. If they spam me, then I block that email (my incoming email) and avoid any future reselling of that address.

Please let me know if this is possible, as I'm looking for a Docker solution to host my own forwarding.

Thanks!

P.S. Didn't know where else to ask this question, so I created it as an issue

Typo in README

And of couse you could also put other dockers on this same machine. :-D
=>
And of course you could also put other dockers on this same machine. :-D

Use of arguments in SMF_CONFIG

Hello,

Is it possible to use the incoming arguments as output email?

I would love if I could set an @domain.com config and use the part before the @ as an argument on the forward email. something like bellow. It would help to set an alias email for each client and then when I receive the mail it can be automatically sorted and tag.

SMF_CONFIG='@testo.com:info+$[email protected]'

Thanks.

generate certificate for mail.domain

Hi,
I have configured a system with multiple docker containers and everything is working fine.
Now I'm trying to generate the certificate for a docker container that runs simple-mail-forwarder (I'm using jrcs/letsencrypt-nginx-proxy-companion).

version: '3'
services:
  mailserver:
    image: zixia/simple-mail-forwarder
    container_name: mailserver
    environment:
      - [email protected]:myemail
      - SMF_DOMAIN=mail.domain.org
      - LETSENCRYPT_HOST=mail.domain.org
      - LETSENCRYPT_EMAIL=myprivateemailaddress
    ports:
      - "25:25"
    restart: always

The system cannot generate the certificate for this container

CA marked some of the authorizations as invalid, which likely means it could not access http://example.com/.well-known/acme-challenge/X. 
Did you set correct path in -d example.com:path or --default_root? 
Are all your domains accessible from the internet? Please check your domains' DNS entries, your host's network/firewall setup and your webserver config. If a domain's DNS entry has both A and AAAA fields set up, some CAs such as Let's Encrypt will perform the challenge validation over IPv6. 
If your DNS provider does not answer correctly to CAA records request, Let's Encrypt won't issue a certificate for your domain (see https://letsencrypt.org/docs/caa/). Failing authorizations: https://acme-v02.api.letsencrypt.org/acme/authz-v3/7728213527
Challenge validation has failed, see error log.

I only need to certificate "mail.domain.org".
I already have the cert for "domain.org" and "www.domain.org" in another container.

Certificate error. fixed CN=simple-mail-forwarder.com

I am using this docker image for a small site.

From a rails app I am able to workaround this certificate issue by doing OPENSSL_VERIFY_MODE=none

But since I fail to workaround the issue from a wordpress site I dug a littlebit and http://www.checktls.com/perl/TestReceiver.pl help me diagnose:

[000.583]       Connection converted to SSL
[000.600]       
Certificate 1 of 2 in chain:
subject= /C=US/ST=Matrix/L=L/O=O/CN=simple-mail-forwarder.com
issuer= /C=US/ST=Matrix/L=L/O=O/CN=simple-mail-forwarder.com                                                
[000.617]       
Certificate 2 of 2 in chain:
subject= /C=US/ST=Matrix/L=L/O=O/CN=simple-mail-forwarder.com
issuer= /C=US/ST=Matrix/L=L/O=O/CN=simple-mail-forwarder.com   
[000.617]       Cert NOT VALIDATED: self signed certificate
[000.618]       So email is encrypted but the domain is not verified
[000.618]       Cert Hostname DOES NOT VERIFY (mail.myappdomain.com != simple-mail-forwarder.com)
[000.618]       So email is encrypted but the host is not verified  

Maybe https://github.com/zixia/docker-simple-mail-forwarder/blob/master/install/init-openssl.sh#L13 should be use SMF_DOMAIN env variable so the certificate could be validated.

WDYT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.