ubergeek77 / Lemmy-Easy-Deploy

Deploy Lemmy the easy way!
MIT License
133 stars 14 forks source link

postfix issue #87

Closed BlueEther closed 2 months ago

BlueEther commented 6 months ago

Did you check the FAQ & Troubleshooting section for answers to common questions and issues?

Yes

Describe the issue

I moved hosts where my lemmy instance lived, copied over all the volumes (a few teething issues) and got almost everything working, exect for postfix dropping send mail attempts

Diagnostic Information

logs of triggering an email event

lemmy-1     | 2024-02-13T08:33:31.021943Z  WARN Error encountered while processing the incoming HTTP request: lemmy_server::root_span_builder: EmailSendFailed: internal client error: No compatible authentication mechanism was found
lemmy-1     | 
lemmy-1     | Caused by:
lemmy-1     |     No compatible authentication mechanism was found
lemmy-1     |    0: lemmy_server::root_span_builder::HTTP request
lemmy-1     |            with http.method=PUT http.scheme="https" http.host=no.lastname.nz http.target=/api/v3/admin/registration_application/approve otel.kind="server" request_id=250105e4-b7fe-4f53-be05-d0f99dd2d3df http.status_code=400 otel.status_code="OK"
lemmy-1     |              at src/root_span_builder.rs:16
lemmy-1     | 2024-02-13T08:33:31.022035Z  INFO actix_web::middleware::logger: 203.184.29.228 'PUT /api/v3/admin/registration_application/approve HTTP/1.1' 400 29 'https://no.lastname.nz/registration_applications' 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' 0.021661    
postfix-1   | 2024-02-13T08:33:31.021565+00:00 33bcd248122f postfix/smtpd[129]: connect from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5]
postfix-1   | 2024-02-13T08:33:31.025061+00:00 33bcd248122f postfix/smtpd[129]: lost connection after EHLO from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5]
postfix-1   | 2024-02-13T08:33:31.025078+00:00 33bcd248122f postfix/smtpd[129]: disconnect from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5] ehlo=1 commands=1
postfix-1   | 2024-02-13T08:33:31.026113+00:00 33bcd248122f postfix/smtpd[129]: connect from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5]
postfix-1   | 2024-02-13T08:33:31.026670+00:00 33bcd248122f postfix/smtpd[129]: lost connection after EHLO from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5]
postfix-1   | 2024-02-13T08:33:31.026989+00:00 33bcd248122f postfix/smtpd[129]: disconnect from lemmy-easy-deploy-lemmy-1.lemmy-easy-deploy_default[172.29.0.5] ehlo=1 commands=1

ubuntu@lemmy:~/Lemmy-Easy-Deploy$ sudo ./deploy.sh -d

==== Docker Information ==== Detected runtime: docker (Docker version 25.0.3, build 4debf41) Detected compose: docker compose (Docker Compose version v2.24.5) Runtime state: OK

==== System Information ==== OS: Linux KERNEL: 5.15.0-1047-oracle (aarch64) HOSTNAME: OK SHELL: bash MEMORY: total used free shared buff/cache available Mem: 11Gi 741Mi 1.0Gi 146Mi 9.9Gi 10Gi Swap: 0B 0B 0B

DISTRO:

PRETTY_NAME="Ubuntu 22.04.3 LTS" NAME="Ubuntu" VERSION_CODENAME=jammy UBUNTU_CODENAME=jammy

==== Lemmy-Easy-Deploy Information ==== Version: 1.3.3

IMAGE CREATED STATUS lemmy-easy-deploy-proxy 6 minutes ago Up 6 minutes ghcr.io/ubergeek77/lemmy-ui:0.19.3 6 minutes ago Up 6 minutes (healthy) ghcr.io/ubergeek77/lemmy:0.19.3 6 minutes ago Up 6 minutes asonix/pictrs:0.5.0 6 minutes ago Up 6 minutes postgres:15-alpine 6 minutes ago Up 6 minutes mwader/postfix-relay 6 minutes ago Up 6 minutes

Integrity: 2cd5fe103e2d1d703edd5b2368a302e2aa56f005044b5aa182dfcb50e4803b02 ./deploy.sh 92c95dfc886792b8df2e9fffb540fc71a35c3bc6fd6c7662134da1545a79457a ./templates/Caddy-Dockerfile.template c1202e70662dd2228da36a35a0f38ec8fc81bec8964d7315d02e8671a58dd7d7 ./templates/Caddyfile.template 2537678c7971df36c1ed95f4228d3cfcb15bb4a28a60d939eaf8dd75b5d64a36 ./templates/cloudflare.snip c494a610bcb4cd1cfc0a4fe4fb0f6d437b2a84a0ad1625daee240e6dd6f1c910 ./templates/compose-email-volumes.snip c9cb4c5fee12930e17798a02ae1bd12e2dc69e149a394c24511bc9d4e6b776d4 ./templates/compose-email.snip 8ea59e18db82eae2c475589bf819987fa76fcc5e2499b5539dc056fe69ac9a08 ./templates/docker-compose.yml.template 2996e76b1fe84c8abd0d36352332781bec9608540372e70b39b0dab76b8150f7 ./templates/lemmy-email.snip 1c202b1b6e87c65b2fcda6035c9fe3f8631d76662907ffd38f24b14686e30647 ./templates/lemmy-email.snip.bk c834cdce9eaf77f38155b404724fdfe66845575386ee516987452aa715642a6f ./templates/lemmy.hjson.template

Custom Files: total 4.0K -rw-rw-r-- 1 1001 1001 45 Feb 13 08:31 customPostfix.env

==== Settings ==== CLOUDFLARE: Yes CADDY_DISABLE_TLS: false CADDY_HTTP_PORT: 80 CADDY_HTTPS_PORT: 443 LEMMY_TLS_ENABLED: true ENABLE_EMAIL: true SMTP_PORT: 25 ENABLE_POSTFIX: true POSTGRES_POOL_SIZE: 5

==== Generated Files ==== Deploy Version: 0.19.3;0.19.3

total 56K drwxr-xr-x 2 0 0 4.0K Feb 11 00:58 caddy -rw-r--r-- 1 0 0 84 Feb 13 08:43 caddy.env -rw-r--r-- 1 0 0 45 Feb 13 08:43 customPostfix.env -rw-r--r-- 1 0 0 2.1K Feb 13 08:43 docker-compose.yml drwxr-xr-x 14 0 0 4.0K Jul 17 2023 lemmy drwxr-xr-x 7 0 0 4.0K Jul 17 2023 lemmy-ui drwxr-xr-x 2 0 0 4.0K Feb 10 00:29 lemmy-ui-themes -rw-r--r-- 1 0 0 50 Jul 17 2023 lemmy.env -rw-r--r-- 1 0 0 587 Feb 13 08:43 lemmy.hjson -rw-r--r-- 1 0 0 49 Jul 17 2023 pictrs.env -rw-r--r-- 1 0 0 34 Feb 13 08:43 postfix.env -rw-r--r-- 1 0 0 39 Feb 11 00:49 postgres.env -rw-r--r-- 1 0 0 51 Feb 11 00:48 postgres.env.bk -rw-r--r-- 1 0 0 14 Feb 13 08:44 version

I attempted to comment out the auth section in the config.env, but that still didn't fix the issue

If true/1, add an email configuration block to lemmy.hjson

ENABLE_EMAIL="true"

The SMTP server to use for email, if ENABLE_EMAIL==true

SMTP_SERVER="postfix"

The login name to use for the SMTP server

SMTP_LOGIN=""

The login password to use for the SMTP server

SMTP_PASSWORD=""

The TLS type to use for SMTP, can be none, tls, or starttls

SMTP_TLS_TYPE="none"

The SMTP port to use for email, if ENABLE_EMAIL==true

SMTP_PORT="25"

The display name to show on emails

SMTP_NOREPLY_DISPLAY="Lemmy NoReply"

The full from address for emails

SMTP_NOREPLY_FROM="noreply@${LEMMY_HOSTNAME}"

If true/1, also deploy the postfix server and configure Lemmy to send emails

Will override ENABLE_EMAIL to true

ENABLE_POSTFIX="true"

I then went into the template dir and edited the templates/lemmy-email.snip:

email: { smtp_server: "{{SMTP_SERVER}}:{{SMTP_PORT}}" smtp_from_address: "{{SMTP_NOREPLY_DISPLAY}} <{{SMTP_NOREPLY_FROM}}>" tls_type: "{{SMTP_TLS_TYPE}}" }


This seems to have fixed the issue of postfix dropping the connection

Is it worth doing a check for no password on postfix? This seems to be the default config
ubergeek77 commented 6 months ago

And postfix was working on your previous host before this config change?

It's possible that the postfix image slightly changed behavior, and doesn't interpret a blank password as an anonymous login anymore.

I'm glad you got it sorted though! I might look into this, but to be honest, this project is not a recent priority for me, and postfix is fairly unsafe to be using in production in general. Maybe in a future update I can simply drop those fields if no username/password is provided.

BlueEther commented 6 months ago

Yeah it was all working fine, no real big issue after I figured what the issue was - just thought I'd give a heads up.

ubergeek77 commented 2 months ago

The upcoming release of Lemmy-Easy-Deploy, I now drop the username and password fields if they are blank.

Thanks for the report!