Email to Gotify notification
A fork of email2pb
This simple script allows to redirect mail input (from postfix, for example) from a certain mail address to a Gotify notification. Useful to send pushes from sources which are able to send email only.
Let's imagine that we want to redirect all emails sent to push@example.com to your Gotify account (and therefore to your mobile devices).
These instructions below were tested on Debian 11, Python 3.9. Requires pycurl
(apt-get install python3-pycurl python2-htm2text
or python3 -m pip install pycurl html2text
)
Bla-bla-bla
First, create shell script which will contain email2gotify call and an API key. If you will directly specify python script with a API key in aliases file - this'll be a major security hole. So our script will be something like this:
#!/bin/sh
/usr/bin/python3 /var/spool/postfix/email2gotify/email2gotify.py --key YOUR_GOTIFY_TOKEN --url YOUR_GOTIFY_ROOT_URL
Let's name it...umm... /var/spool/postfix/email2gotifyemail2gotify
And make it executable:
chmod +x /var/spool/postfix/email2gotify/email2gotify
Why there? My example was tested in Debian, and postfix's home dir on Ubuntu is /var/spool/postfix Remember, postfix should be able to acces your script.
Open /etc/aliases file and append a line there:
push: |/var/spool/postfix/email2gotify/email2gotify
Save the file and execute newaliases
command.
Send email to push@example.com and, if it didn't work, check /var/log/mail.log
Thats it.