binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.55k stars 730 forks source link

ntfy filtering for mail over http #1117

Open lutzky opened 6 months ago

lutzky commented 6 months ago

:bulb: Idea

My home server (and workstation) occasionally send emails, e.g. on cron job failures. https://docs.ntfy.sh/examples/#cronjobs shows how to do this manually for cron jobs (and doesn't forward stdout). Another way of doing it is using cron's (or anacron's) built-in MAILTO component, and creating a .forward file with contents such as:

ntfy-my-personal-cron@ntfy.sh
"| curl -H 'Authorization: Bearer tk_tokentokentoken' -H 'X-Tags: email' -d '@-' https://ntfy.mydomain.com/my-personal-cron"

That first line works nicely; e.g. for a sudo password failure, you get a notification that looks like this:

image

However, that second one gets output that looks like this:

image

Now, in my case, mydomain.com runs on CloudFlare, and it's fairly easy to expose HTTP that way, even when opening ports is impossible or undesirable. This doesn't work for email, so I can't send email to my-person-cron@ntfy.mydomain.com.

What would be really nice is if I could supply a header like X-Filter-this-as-though-it-is-email: true for cases like this. Essentially, this should act like smtpSession.Data - extracting the subject, determining if it's HTML, managing attachments, etc.

:computer: Target components - ntfy server