license
Release

This project is a naive port of the r2e project to golang.

Rationale

I prefer to keep my server(s) pretty minimal, and replacing r2e allowed
me to remove a bunch of Python packages I otherwise have 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.

Build without Go Modules (Go before 1.11)

go get -u github.com/skx/rss2email

Build with Go Modules (Go 1.11 or higher)

git clone https://github.com/skx/rss2email ;# make sure to clone outside of GOPATH
cd rss2email
go install

Once you have a binary 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

You can view the currently configured feeds via the list subcommand:

 $ rss2email list

Or delete a feed 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
 */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.

Initial Run

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

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

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.

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.
  • 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.

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.

Steve



Source link