Code Monkey home page Code Monkey logo

docker-postfix's Introduction

postfix

Star this repository if it is useful for you.
Docker Stars Docker Pulls license

English
Japanese (日本語)

Supported tags and respective Dockerfile links

Supported architectures: (more info)

amd64, arm64(for Raspberry Pi)

Image summary

FROM rockylinux:8  
MAINTAINER "Hiroki Takeyama"

ENV TIMEZONE Asia/Tokyo

ENV HOSTNAME smtp.example.com  
ENV DOMAIN_NAME example.com

ENV MESSAGE_SIZE_LIMIT 10240000

ENV AUTH_USER user  
ENV AUTH_PASSWORD password

ENV DISABLE_SMTP_AUTH_ON_PORT_25 true

ENV ENABLE_DKIM true  
ENV DKIM_KEY_LENGTH 1024  
ENV DKIM_SELECTOR default

# SSL Certificates  
VOLUME /ssl_certs
# DKIM Keys  
VOLUME /dkim_keys

# SMTP  
EXPOSE 25  
# Submission  
EXPOSE 587  
# SMTPS  
EXPOSE 465

How to use

You can send a mail using a secure connection (SSL/TLS).
In advance you may need to add SPF, DKIM, DMARC records to your DNS server in order that your mail avoids being marked as a spam.

version: '3'  
services:  
  postfix:  
    image: takeyamajp/postfix  
    ports:  
      - "8025:25"  
      - "8587:587"  
      - "8465:465"  
    volumes:  
      - /my/own/certs:/ssl_certs  
      - /my/own/keys:/dkim_keys  
    environment:  
      TIMEZONE: "Asia/Tokyo"  
      HOSTNAME: "smtp.example.com"  
      DOMAIN_NAME: "example.com"  
      MESSAGE_SIZE_LIMIT: "10240000"  
      AUTH_USER: "user"  
      AUTH_PASSWORD: "password"  
      DISABLE_SMTP_AUTH_ON_PORT_25: "true"  
      ENABLE_DKIM: "true"  
      DKIM_KEY_LENGTH: "1024"  
      DKIM_SELECTOR: "default"

Time zone

You can use any time zone such as America/Chicago that can be used in Rocky Linux.

See below for zones.
https://www.unicode.org/cldr/charts/latest/verify/zones/en.html

Message size limit

The maximum size in bytes of a mail you can send. (attached files included)
Increase the value of MESSAGE_SIZE_LIMIT, if you send a mail of more than 10MB size.

Username

The user name used at authentication will be a format like a e-mail address (e.g. [email protected]).
It won't be included in a sent mail, so you can use any sender address according to your purpose.

Port No.

You can usually use submission port 587.
Use port 465 if your mail client needs SMTPS (SMTP over SSL), then ignore a displayed certificate warning.
Port 25 is disabled by default. Set DISABLE_SMTP_AUTH_ON_PORT_25 to false If you want to use it.

SSL certificates

The self-signed certificate will be created automatically into the volume '/ssl_certs', and it can be added to your OS (e.g. Windows, Linux, iOS, and Android) as the root certificate in order to avoid warnings on your mail clients.

If you have valid server certificates, you can use them.
And if you also have the intermediate certificate, append after the server certificate.

cat server_cert.pem intermediate_CA.pem > cert.pem

DKIM keys

The public key will be displayed on 'docker logs'.
Mount the volume '/dkim_keys' on your host machine. Otherwise the key will be changed every time this container starts.
You can set DKIM_KEY_LENGTH to 2048 if your DNS server supports TXT records of more than 255 length.
If you have a mail server besides this container, you will need to change DKIM_SELECTOR from 'default' so that it doesn't overlap with other one.

Logging

This container logs all failed and successful deliveries to 'docker logs'.

Use the following command to view the logs in real time.

docker logs -f postfix

docker-postfix's People

Contributors

takeyamajp 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

Watchers

 avatar  avatar  avatar

docker-postfix's Issues

Recipient address rejected: Access denied

I really like the project, but I am failing to send an example email; apparently some configuration is missing.
Passing custom /etc/postfix configs seems to be impossible due to generation of those at runtime.

I am currently using the following bash script (domain changed to smtp.example.org):

FROM_ADDRESS="[email protected]"
TO_ADDRESS="[email protected]"
SUBJECT="Test-E-Mail"
BODY="Test E-Mail from Docker-Postfix-Container."

MAIL_SERVER="192.168.1.182"
MAIL_PORT=8587

EMAIL_FILE="$(mktemp)"
echo -e "From: $FROM_ADDRESS\nTo: $TO_ADDRESS\nSubject: $SUBJECT\n\n$BODY" > "$EMAIL_FILE"

if ! (echo -e "EHLO $MAIL_SERVER\nMAIL FROM: <$FROM_ADDRESS>\nRCPT TO: <$TO_ADDRESS>\nDATA\n$(cat "$EMAIL_FILE")\n.\n" | nc "$MAIL_SERVER" "$MAIL_PORT"); then
  echo "ERROR sending E-Mail."
  exit 1
fi
echo "E-Mail sent successfully"
rm "$EMAIL_FILE"

which produces this output:

$ bash send_mail.sh 
220 smtp.example.org ESMTP
250-smtp.example.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN CRAM-MD5
250-AUTH=PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
250 2.1.0 Ok
554 5.7.1 <[email protected]>: Recipient address rejected: Access denied
554 5.5.1 Error: no valid recipients
221 2.7.0 Error: I can break rules, too. Goodbye.
E-Mail send successfully

Thankful for any assistance

Feature request: Log Subject

configure postfix with log header with subject

Step:1 Edit ‘/etc/postfix/main.cf’ file & uncomment below line:
#header_checks = regexp:/etc/postfix/header_checks
Step:2 Append the below line in ‘/etc/postfix/header_checks’ [at the bottom]
/^Subject:/     WARN
Step:3 Run postmap to apply the new configuration in /etc/postfix/header_checks
[root@server1 ~]# postmap /etc/postfix/header_checks
Step:4 Restart or Reload the postfix server
[root@server1 ~]# systemctl restart postfix
[root@server1 ~]# postfix reload
Step:5 Login to your Roundcube webmail and send an test with the subject line: "Fwd: New! Machine Learning: Algorithms in the Real World"

Authentication errors

I install everything according to the instructions, but then I write that the login and password are not correct when connecting to the smtp. tried user=[email protected] user = test

OpenDKIM Failed to start OpenDKIM Milter.

I think the main.cf is inside the docker (/etc/postfix/main.cf)
If I try to start the opendkim service (on ubuntu 22.04), I get an error).
The reccomendation is to add the following int o the main.cf.
Could you please check this?

#Milter - DKIM, DMARC, SPF
#########################################################################

milter_default_action                   = accept
milter_protocol                         = 6

smtpd_milters =
    inet:127.0.0.1:8892

non_smtpd_milters = 
    ${smtpd_milters}

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.