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.
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.
You can find Dockerfiles and images here.
--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
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
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