Send emails using Docker container on Raspberry Pi 3

Send emails using Docker container on Raspberry Pi 3

Although it is written as Raspberry Pi 3, it uses a Docker image that supports multi-CPU architectures (linux/amd64, linux/arm64, linux/arm/v7), so I think it will work in those environments as well.

Introduction

I found a Docker image that can send mail without authentication from within the LAN, so refer to "[Build an image corresponding to Docker's" multi-CPU architecture "(https://dev.classmethod.jp/articles/docker-multi-architecture-image-build/)" (https://dev.classmethod.jp/articles/docker-multi-architecture-image-build/) ", linux/amd64, linux/arm64, linux I created an image corresponding to/arm/v7 and tried running a Docker container on Raspberry Pi 3 Model B +. The created Docker image is placed in Docker Hub. You can send emails from NAS, appliances, and applications on the Raspberry Pi via the Postfix Docker container.

Due to the limitation of OP25B (Outbound Port 25 Blocking), the mail is not sent directly from the Docker container to the other mail server, but is sent by relaying the external SMTP server. Therefore, you need an SMTP server that allows connection information and relays from the SMTP server of the contracted provider.

Reference information

Repository

You can find Dockerfiles and images here.

Things to prepare

--SMTP server connection information of the contracted provider -Raspberry Pi 3 Model B + (I don't have Raspberry Pi 4, so I have confirmed the operation with Raspberry Pi 3. I think it will also work with Raspberry Pi 4.) --docker execution environment

Launch Docker container

Start the container using the image placed in Docker Hub.

docker run -d --name postfix -p "25:25"  \
       -e SMTP_SERVER=smtp.bar.com \
       -e [email protected] \
       -e SMTP_PASSWORD=XXXXXXXX \
       -e SERVER_HOSTNAME=helpdesk.mycompany.com \
       revsystem/postfix:latest

Specify the authentication information of each relay destination SMTP server. SERVER_HOSTNAME specifies the host name of the Docker container. If you do not specify SMTP_PORT, port 587 is set by default. When port 465 is open instead of port 587 such as J: COM. Specify port 465 for SMTP_PORT. Example)

docker run -d --name postfix -p "25:25"  \
       -e SMTP_SERVER=smtp.bar.com \
       -e SMTP_PORT=465
       -e [email protected] \
       -e SMTP_PASSWORD=XXXXXXXX \
       -e SERVER_HOSTNAME=helpdesk.mycompany.com \
       revsystem/postfix:latest

Send email

We are forwarding port 25 of the Docker host to port 25 of the Docker container. You can send an email from a device in the LAN by specifying the IP address of the Docker host and port number 25 as the SMTP server name.

When testing the transmission, I tried sending an email from Raspberry Pi. Use [Python] and [Postfix]. can be tested by placing sendMail.py published on the Docker host and running to_addr, from_addr as your email address.

Recommended Posts

Send emails using Docker container on Raspberry Pi 3
Install Docker on Raspberry Pi
I installed Docker on my Raspberry Pi 3
Launched Redmine with Docker on Raspberry Pi 3
Install Docker on Raspberry Pi 4 and Raspberry Pi OS 64bit
Radiko recording server on Raspberry Pi 4 (Docker unused)
Run the Android emulator on Docker using Android Emulator Container Scripts
[Docker] Build an Apache container on EC2 using dockerfile
Put Ubuntu 20.04.1 on Raspberry Pi 4
Minecraft server on Raspberry Pi 4
The key to running Docker on Raspberry Pi 4 (Ubuntu server 20.04)
Put Redmine docker container in Raspberry Pi 4 Model B 2GB
Try Hello World using plain Java on a Docker container
Install MariaDB on Raspberry Pi OS
Try using Redmine on Mac docker
Run React on a Docker container
Try putting CentOS 8 on Raspberry Pi 3
Run GUI application on Docker container
Note: setting javaMail on Raspberry Pi
Run PureScript on a Docker container
Using Docker on Windows10 Home WSL2
Install Docker and docker-compose on Raspberry Pi 4, Linux (Debian) and Windows 10, respectively
Raspberry Pi Kubernetes and Docker downgraded story
Put Kanban in Docker of Raspberry Pi 3
Headless install of Ubuntu 20.10 on Raspberry Pi
Run NordVPN on Docker (Windows) Ubuntu container
Quick build maven project using maven docker container
Send an email using JavaMail on AWS
Install CentOS 7 on Raspberry pi 4 Model B
Serially connect to Ubuntu on Raspberry Pi
Run GUI application on Docker container (Japanese input)
Extract key phrases using Text Analytics Docker container
Build a Kotlin app using OpenJDK's Docker container
I couldn't install docker with raspberry pi2 b +.
Update container image with KUSANAGI Runs on Docker
I tried running Ansible on a Docker container
Try using another Servlet container Jetty with Docker
Liberty on Docker
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
Small Docker container
[Amateur remarks] CentOS 8 was installed on Raspberry Pi 4 8G, and Wordpress was built using Docker-Compose.
Redmine on Docker
Build Ubuntu 20.04 LTS desktop environment on Raspberry Pi 4 (+ Japanese)
How to run javafx with Raspberry Pi Posted on 2020/07/12
Systemctl cannot be used on Ubuntu inside Docker container
Deploy laravel using docker on EC2 on AWS ① (Create EC2 instance)
GitHub Actions/Cache: Cache bundle installed gems on Docker container
Display characters on I2C 1602 LCD with Raspberry Pi 3 & Java
I tried using Docker Desktop for Windows on Windows 10 Home