Another Postfix relay docker container with OAUTH2, but working with Microsoft 365
Adapted from https://github.com/takeyamajp/docker-postfix
tarickb/sasl-xoauth2 installed into image https://github.com/tarickb/sasl-xoauth2
- clone the project (git clone https://github.com/mauroreggio/postfix-365.git)
- edit docker-compose.yml with right parameters
- run "docker-compose up" for interactive log on console or
- run "docker-compose up -d" for run like a daemon in background (docker ps -a for check the status)
Based on Alma Linux 9.5, the active docker do:
- Read all ENV variables in docker-compose.yml
- Copy ./scripts folder into the container
- Use ./scripts/entrypoint.sh as a startup script (that run all other scripts)
After run the container, remember last step: create Initial Access Token
https://github.com/tarickb/sasl-xoauth2#initial-access-token-2
This step consist in:
- bash into the running container
- run the script that assist you
- this create an [email protected] file in /etc/tokens folder of the container, mapped on the ./tokens local folder.
NOT TESTED: the "sasl-xoauth2-tool" is a perl script. If you desire you can install and run out of the container and create the [email protected] file in the ./tokens local folder. Don't forget to assign postfix:postfix own group:user to the file from the container bash (only first time, is persistent)
My "sasl-xoauth2-tool" example is:
sasl-xoauth2-tool get-token outlook \
/etc/tokens/[email protected] \
--tenant= your tenant id \
--client-id= your client id (id of the application created on Azure Entra ID)
docker exec -it postfix bash
/usr/sbin/postfix -c /etc/postfix start
/usr/sbin/postfix -c /etc/postfix stop
docker build -t localhost/postfix-365:tag .
(or if you want build without any docker cache):
docker build --no-cache -t localhost/postfix-365:1.0.0 .