mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 16:35:53 +02:00
[GH-ISSUE #265] SMTP server error occurs when 'Content-Type' header is not present #205
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#205
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?
Originally created by @dmbonsall on GitHub (May 21, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/265
I encountered an error whenever an email is sent to NTFY without a 'Content-Type' header. This error was found in docker image v1.23.0. Error was discovered while setting up email notifications from a pfsense appliance --> ntfy.
I believe that I have found the root cause of the problem, and I have proposed a solution below. I wanted to start off submitting an issue since I don't know go, but if nobody has time to address it, I can see if I can get a dev env up and running to submit a PR with a fix. Just let me know :)
Steps to reproduce:
Create test email file without 'Content-Type' header:
Send to server with NC:
Server response:
Diagnosis
In
ntfy/server/smtp_server.go::readMailBody, the problem is with the line:If 'Content-Type' header isn't set on the message, then
msg.Header.Get("Content-Type")with return"". According to themimelibrary source, the functionParseMediaTypereturns an error ifmediatypeargument is"". Approximate stack trace is something like:The error there is consistent with the SMTP server log message and error code above.
Proposed solution
Update
ntfy/server/smtp_server.go::readMailBodyto check if 'Content-Type' is set, and if not, default it to "text/plain" or some other, sensible default. This will ensure that any notification systems who do not set "Content-Type" will still have their notifications accepted.@binwiederhier commented on GitHub (May 21, 2022):
That has to be the most detailed bug report I have ever received. Thank you!! Will have it fixed in no time.
@binwiederhier commented on GitHub (May 22, 2022):
Had to read the MIME RFC to see if emails without content type are allowed, and that looks to be the case:
From https://datatracker.ietf.org/doc/html/rfc1521#page-13:
I fixed the issue here just like you proposed (
github.com/binwiederhier/ntfy@2abd6a57ee), and it'll be in the next release.Thank you for reporting the bug!
@dmbonsall commented on GitHub (May 22, 2022):
Happy to help, thanks for such a quick turn-around on this! Good find on the RFC docs, it's good to know the fix complies with the spec.
@ColonelThirtyTwo commented on GitHub (May 26, 2022):
The swaks testing tool sends such emails.