Skip to content

Another Postfix relay with OAUTH2 but working with Microsoft 365. Docker version.

Notifications You must be signed in to change notification settings

mauroreggio/postfix-365

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postfix-oauth2 for Microsoft 365

Another Postfix relay docker container with OAUTH2, but working with Microsoft 365

USE IT AT YOUR OWN RISK

Adapted from https://github.com/takeyamajp/docker-postfix
tarickb/sasl-xoauth2 installed into image https://github.com/tarickb/sasl-xoauth2

Usage (work in progres)

  • 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)

Debug

bash into running container

docker exec -it postfix bash

within the running container

/usr/sbin/postfix -c /etc/postfix start
/usr/sbin/postfix -c /etc/postfix stop

Modify and create a new docker image

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 .