[PR #621] [MERGED] Make email publishing work, when access-control is enabled #1355

Closed
opened 2026-05-07 01:01:44 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/621
Author: @tamcore
Created: 2/19/2023
Status: Merged
Merged: 2/20/2023
Merged by: @binwiederhier

Base: mainHead: feature/email-with-access-control


📝 Commits (1)

  • e892b99 add support to pass access-token for e-mail publishing

📊 Changes

3 files changed (+40 additions, -0 deletions)

View changed files

📝 docs/publish.md (+5 -0)
📝 server/smtp_server.go (+14 -0)
📝 server/smtp_server_test.go (+21 -0)

📄 Description

This will fix #420, by allowing emails in the format ${prefix}-${topic}+${token}@${host}, so the user can pass a token with write-permissions to the defined topic.

A container image to test it with is available via ghcr.io/tamcore/ntfy:v2.0.1@sha256:e6616f3531f9960da1f0ea918feb73faa8ffa0794a58d0d606eb131f911a7650


Tests

Without token

root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525
> EHLO example.com
> MAIL FROM: phil@example.com
> RCPT TO: ntfy-mytopic@ntfy.ntfy.svc.cluster.local
> DATA
> Subject: Email for you
> Content-Type: text/plain; charset="UTF-8"
>
> Hello from 🇩🇪
> .
> EOC
220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready
250-Hello example.com
250-PIPELINING
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-CHUNKING
250-AUTH PLAIN
250 SIZE 1048576
250 2.0.0 Roger, accepting mail from <phil@example.com>
250 2.0.0 I'll make sure <ntfy-mytopic@ntfy.ntfy.svc.cluster.local> gets this
354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>
554 5.0.0 Error: transaction failed, blame it on the weather: error: {"code":40301,"http":403,"error":"forbidden","link":"https://ntfy.sh/docs/publish/#authentication"}

With invalid token

root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525
> EHLO example.com
> MAIL FROM: phil@example.com
> RCPT TO: ntfy-mytopic+tk_invalidtoken@ntfy.ntfy.svc.cluster.local
> DATA
> Subject: Email for you
> Content-Type: text/plain; charset="UTF-8"
>
> Hello from 🇩🇪
> .
> EOC
220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready
250-Hello example.com
250-PIPELINING
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-CHUNKING
250-AUTH PLAIN
250 SIZE 1048576
250 2.0.0 Roger, accepting mail from <phil@example.com>
250 2.0.0 I'll make sure <ntfy-mytopic+tk_invalidtoken@ntfy.ntfy.svc.cluster.local> gets this
354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>
554 5.0.0 Error: transaction failed, blame it on the weather: error: {"code":40101,"http":401,"error":"unauthorized","link":"https://ntfy.sh/docs/publish/#authentication"}

With valid token

root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525
> EHLO example.com
> MAIL FROM: phil@example.com
> RCPT TO: ntfy-mytopic+tk_JhbsnoMrgy2FcfHeofv97Pi5uXaZZ@ntfy.ntfy.svc.cluster.local
> DATA
> Subject: Email for you
> Content-Type: text/plain; charset="UTF-8"
>
> Hello from 🇩🇪
> .
> EOC
220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready
250-Hello example.com
250-PIPELINING
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-CHUNKING
250-AUTH PLAIN
250 SIZE 1048576
250 2.0.0 Roger, accepting mail from <phil@example.com>
250 2.0.0 I'll make sure <ntfy-mytopic+tk_JhbsnoMrgy2FcfHeofv97Pi5uXaZZ@ntfy.ntfy.svc.cluster.local> gets this
354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>
250 2.0.0 OK: queued

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/621 **Author:** [@tamcore](https://github.com/tamcore) **Created:** 2/19/2023 **Status:** ✅ Merged **Merged:** 2/20/2023 **Merged by:** [@binwiederhier](https://github.com/binwiederhier) **Base:** `main` ← **Head:** `feature/email-with-access-control` --- ### 📝 Commits (1) - [`e892b99`](https://github.com/binwiederhier/ntfy/commit/e892b994c348a288e2a4593eb4add9c2f3d3b561) add support to pass access-token for e-mail publishing ### 📊 Changes **3 files changed** (+40 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/publish.md` (+5 -0) 📝 `server/smtp_server.go` (+14 -0) 📝 `server/smtp_server_test.go` (+21 -0) </details> ### 📄 Description This will fix #420, by allowing emails in the format `${prefix}-${topic}+${token}@${host}`, so the user can pass a token with write-permissions to the defined topic. A container image to test it with is available via `ghcr.io/tamcore/ntfy:v2.0.1@sha256:e6616f3531f9960da1f0ea918feb73faa8ffa0794a58d0d606eb131f911a7650` --- ## Tests ### **Without token** ``` root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525 > EHLO example.com > MAIL FROM: phil@example.com > RCPT TO: ntfy-mytopic@ntfy.ntfy.svc.cluster.local > DATA > Subject: Email for you > Content-Type: text/plain; charset="UTF-8" > > Hello from 🇩🇪 > . > EOC 220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready 250-Hello example.com 250-PIPELINING 250-8BITMIME 250-ENHANCEDSTATUSCODES 250-CHUNKING 250-AUTH PLAIN 250 SIZE 1048576 250 2.0.0 Roger, accepting mail from <phil@example.com> 250 2.0.0 I'll make sure <ntfy-mytopic@ntfy.ntfy.svc.cluster.local> gets this 354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF> 554 5.0.0 Error: transaction failed, blame it on the weather: error: {"code":40301,"http":403,"error":"forbidden","link":"https://ntfy.sh/docs/publish/#authentication"} ``` ### **With invalid token** ``` root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525 > EHLO example.com > MAIL FROM: phil@example.com > RCPT TO: ntfy-mytopic+tk_invalidtoken@ntfy.ntfy.svc.cluster.local > DATA > Subject: Email for you > Content-Type: text/plain; charset="UTF-8" > > Hello from 🇩🇪 > . > EOC 220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready 250-Hello example.com 250-PIPELINING 250-8BITMIME 250-ENHANCEDSTATUSCODES 250-CHUNKING 250-AUTH PLAIN 250 SIZE 1048576 250 2.0.0 Roger, accepting mail from <phil@example.com> 250 2.0.0 I'll make sure <ntfy-mytopic+tk_invalidtoken@ntfy.ntfy.svc.cluster.local> gets this 354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF> 554 5.0.0 Error: transaction failed, blame it on the weather: error: {"code":40101,"http":401,"error":"unauthorized","link":"https://ntfy.sh/docs/publish/#authentication"} ``` ### **With valid token** ``` root@ubuntu:/# cat << EOC | nc -N ntfy.ntfy.svc.cluster.local 2525 > EHLO example.com > MAIL FROM: phil@example.com > RCPT TO: ntfy-mytopic+tk_JhbsnoMrgy2FcfHeofv97Pi5uXaZZ@ntfy.ntfy.svc.cluster.local > DATA > Subject: Email for you > Content-Type: text/plain; charset="UTF-8" > > Hello from 🇩🇪 > . > EOC 220 ntfy.ntfy.svc.cluster.local ESMTP Service Ready 250-Hello example.com 250-PIPELINING 250-8BITMIME 250-ENHANCEDSTATUSCODES 250-CHUNKING 250-AUTH PLAIN 250 SIZE 1048576 250 2.0.0 Roger, accepting mail from <phil@example.com> 250 2.0.0 I'll make sure <ntfy-mytopic+tk_JhbsnoMrgy2FcfHeofv97Pi5uXaZZ@ntfy.ntfy.svc.cluster.local> gets this 354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF> 250 2.0.0 OK: queued ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:01:44 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1355
No description provided.