bokysan / docker-postfix

Multi architecture simple SMTP server (postfix null relay) host for your Docker and Kubernetes containers. Based on Debian/Ubuntu/Alpine.
MIT License
535 stars 149 forks source link

boky/postfix:4.3.0-alpine (on Alpine host) no mechanism available #215

Open mauroreggio opened 1 week ago

mauroreggio commented 1 week ago

Hi. Thanks for this project. Run boky/postfix:4.3.0-alpine on an Alpine 3.20 host, try relay to Microsoft 365, with OAUTH2, i receive this error:

*postfix | 2024-10-06T15:16:41.845278+00:00 WARNING postfix/smtp[278]: sasl-xoauth2: Exception during init: Line 2, Column 18#012 Missing ',' or '}' in object declaration#012 postfix | 2024-10-06T15:16:41.845404+00:00 WARNING postfix/smtp[278]: sasl_client_add_plugin(): entry_point(): failed for plugname sasl-xoauth2: generic failure postfix | 2024-10-06T15:16:41.845466+00:00 DEBUG postfix/smtp[278]: _sasl_plugin_load failed on sasl_client_plug_init for plugin: sasl-xoauth2 postfix | 2024-10-06T15:16:41.857557+00:00 INFO postfix/smtpd[273]: disconnect from unknown[192.168.0.4] ehlo=1 mail=1 rcpt=1 data=1 commands=4 postfix | 2024-10-06T15:16:42.088207+00:00 WARNING postfix/smtp[278]: warning: SASL authentication failure: No worthy mechs found postfix | 2024-10-06T15:16:42.088976+00:00 INFO postfix/smtp[278]: BE042241A19: SASL authentication failed; cannot authenticate to server smtp.office365.com[52.98.242.226]: no mechanism available postfix | 2024-10-06T15:16:42.196293+00:00 WARNING postfix/smtp[278]: warning: SASL authentication failure: No worthy mechs found postfix | 2024-10-06T15:16:42.197323+00:00 INFO postfix/smtp[278]: BE042241A19: SASL authentication failed; cannot authenticate to server smtp.office365.com[52.98.237.162]: no mechanism available postfix | 2024-10-06T15:16:42.306844+00:00 WARNING postfix/smtp[278]: warning: SASL authentication failure: No worthy mechs found postfix | 2024-10-06T15:16:42.306878+00:00 INFO postfix/smtp[278]: BE042241A19: SASL authentication failed; cannot authenticate to server smtp.office365.com[52.98.237.146]: no mechanism available postfix | 2024-10-06T15:16:42.413490+00:00 WARNING postfix/smtp[278]: warning: SASL authentication failure: No worthy mechs found**

Try add to host libsasl (apk add cyrus-sasl) but not know if i'm in the right direction and/or if what i try add to the host is correct. But the docker image not have all it need for run?

Here my docker-compose.yml

_name: postfix-docker services: postfix: restart: unless-stopped container_name: postfix environment:

Thanks. Mauro.

mauroreggio commented 1 week ago

I do some debug. Enter in the container shell and explore postfix configuration. This is how "/etc/postfix/main.cf" is created (only the final part)

inet_protocols = ipv4 meta_directory = /etc/postfix shlib_directory = /usr/lib/postfix mydestination = relay_domains = header_size_limit = 4096000 smtpd_delay_reject = yes smtpd_helo_required = yes smtpd_client_restrictions = permit_mynetworks,reject smtpd_helo_restrictions = permit_mynetworks,reject_invalid_helo_hostname,permit smtpd_sender_restrictions = permit_mynetworks,reject relayhost = smtp.office365.com:587 smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_sasl_auth_enable = yes smtp_sasl_password_maps = lmdb:/etc/postfix/sasl_passwd smtp_sasl_security_options = smtp_sasl_tls_security_options = noanonymous smtp_sasl_mechanism_filter = xoauth2 smtp_tls_session_cache_database = lmdb:${data_directory}/smtp_scache message_size_limit = 0 myhostname = mail01 mynetworks = 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 smtp_tls_security_level = encrypt

I read this page where there are some suggestion for configure postfix with oauth2, and merge with our config: https://mmogilvi.users.sourceforge.net/software/oauthbearer.html In our config:

Can be this the problem? I try create the file myself, but i not know exactly what the file must contain.

Thanks. Mauro.