This project is a naive port of the python-based r2e I used for many years to golang.
I prefer to keep my server(s) pretty minimal, and replacing r2e
allowed
me to remove a bunch of Python packages I otherwise had no need for:
steve@ssh ~ $ sudo dpkg --purge rss2email
Removing rss2email (1:3.9-2.1) ...
ssh ~ # apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
python-xdg python3-bs4 python3-chardet python3-feedparser python3-html2text
python3-html5lib python3-lxml python3-six python3-webencodings
0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
This project, being built in go, is self-contained and easy to deploy without the need for additional external libraries.
There are two ways to install this project from source, which depend on the version of the go version you're using.
If you prefer you can fetch a binary from our release page. Currently there is only a binary for Linux (amd64) due to the use of cgo
in our dependencies.
go get -u github.com/skx/rss2email
git clone https://github.com/skx/rss2email ;# make sure to clone outside of GOPATH
cd rss2email
go install
The binary has integrated support for TAB-completion, for bash. To enable this update your dotfiles to include the following:
source <(./rss2email bash-completion)
Once you have installed the application you'll need to configure the feeds to monitor. To add a new feed use the add
sub-command:
$ rss2email add https://example.com/blog.rss
$ rss2email add https://example.net/index.rss
$ rss2email add https://example.com/foo.rss
If you have a list of feeds stored in an OPML file you can import them in a single-step via the import
sub-command:
$ rss2email import feeds.opml
The list of feeds can be displayed via the list
subcommand:
$ rss2email list
NOTE: You can add
-verbose
to list the number of entries present in each feed, and get an idea of the age of entries.
Removing a feed from the list is done by specifying the item to remove:
$ rss2email delete https://example.com/foo.rss
NOTE: Feeds are stored in
~/.rss2email/feeds
, you might prefer to edit that directly. Just add one URI per line.
Once you've added your feeds you should then add the binary to your
crontab
, to ensure it runs regularly to actually send you the emails.
You should add something similar to this to your crontab
:
# Announce feed-changes via email four times an hour
*/15 * * * * $HOME/go/bin/rss2email cron recipient@example.com
When new items appear in the feeds they will then be sent to you via email.
Each email will be multi-part, containing both text/plain
and text/html
versions of the new post(s). There is a default template which should contain
the things you care about:
- A link to the item posted.
- The subject/title of the new feed item.
- The HTML and Text content of the new feed item.
If you wish you may customize the template which is used to generate the notification email, see customization for details.
We record the state of feed-entries beneath ~/.rss2email/seen
, and these entries are automatically pruned over time.
When you add a new feed all the items will initially be unseen/new, and this means you'll receive a flood of emails if you were to run:
$ rss2email add https://blog.steve.fi/index.rss
$ rss2email cron user@domain.com
To avoid this you can use the -send=false
flag, which will merely
record each item as having been seen, rather than sending you emails:
$ rss2email add https://blog.steve.fi/index.rss
$ rss2email cron -send=false user@domain.com
Because this application is so minimal there are a number of assumptions baked in:
- We assume that
/usr/sbin/sendmail
exists and will send email successfully. - We assume the recipient and sender email addresses can be the same.
- i.e. If you mail output to
bob@example.com
that will be used as the sender address. - You can change the default sender via the customization process described next if you prefer though.
- i.e. If you mail output to
By default the emails are sent using a template file which is embedded in the application. You can override the template by creating the file ~/.rss2email/email.tmpl
, if that is present then it will be used instead of the default.
If you're a developer who wishes to submit changes to the embedded version you should carry out the three-step process to make your change.
- First of all edit
data/email.tmpl
, this is the source of the template. - Next run the implant tool.
- This is responsible for reading the file, and embedding it into the file
static.go
, which is then included in the binary when the project is compiled.
- This is responsible for reading the file, and embedding it into the file
- Rebuild the application to update the embedded copy
go build .
- This will ensure that the changes you made to
data/email.tmpl
are actually contained within your binary, and will be used the next time you launch it.
- This will ensure that the changes you made to
You can view the default template via the following command:
$ rss2email list -template
The default template contains a brief header documenting the available fields, and functions, which you can use. As the template uses the standard Golang text/template facilities you can be pretty creative with it!
This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via .github/run-tests.sh which is used by the github-action-tester action.
Releases are automated in a similar fashion via .github/build, and the github-action-publish-binaries action.