mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 08:26:00 +02:00
[PR #1620] [MERGED] fix(smtp): preserve <br> line breaks in HTML emails #1667
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#1667
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/binwiederhier/ntfy/pull/1620
Author: @uzkikh
Created: 2/21/2026
Status: ✅ Merged
Merged: 2/21/2026
Merged by: @binwiederhier
Base:
main← Head:fix/smtp-html-br-linebreaks📝 Commits (1)
2e49938fix(smtp): preserveline breaks in HTML emails
📊 Changes
2 files changed (+41 additions, -4 deletions)
View changed files
📝
server/smtp_server.go(+4 -0)📝
server/smtp_server_test.go(+37 -4)📄 Description
Context
HTML-only emails (e.g. from Synology DSM 7.3 Task Scheduler) use
<br>tags for line breaks. The existing implementation passed the raw HTML body to bluemonday withAddSpaceWhenStrippingTag(true), which replaces every tag including<br>with a space. This caused all notification content to appear on a single unreadable line.The ntfy notification before the fix
Task Scheduler has completed a scheduled task. Task: daily-backup Start time: Mon, 01 Jan 2026 02:00:00 +0000 Current status: 0 (Normal) From MyNAS
The ntfy notification after the fix
Task Scheduler has completed a scheduled task.
Task: daily-backup
Start time: Mon, 01 Jan 2026 02:00:00 +0000
Current status: 0 (Normal)
From MyNAS
Steps to reproduce
Root cause
The
readHTMLMailBody()function usedbluemonday.StrictPolicy().AddSpaceWhenStrippingTag(true)which replaces all tags including<br>with spaces, discarding line break semantics.Fix
Convert
<br>tags to newlines before passing to bluemonday. The regex covers all variants:<br>,<BR>,<br/>,<BR />.Tests
TestSmtpBackend_HTMLOnly_FromDiskStationandTestSmtpBackend_HTMLEmailto reflect correct outputTestSmtpBackend_HTMLEmail_BrTagsPreservedcovering the Synology Task Scheduler email formatRelated to #690
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.