Engineer in Tokyo

Twitter reply updates via e-mail

I just set up Plagger to send me e-mails to my cellphone and gmail when there are updates to my replies rss feed on twitter. This took way longer than anticipated because of how long it took to install and configure Plagger properly.

First installing it took a long time. I installed it via cpan and Plagger has a huge number of dependencies. Many of the dependencies are not set properly so cpan fails to install it more often then not. I had to force install the IO::Socket::SSL package because the tests failed. I didn't need TLS for mail and it's an optional package so I'm not sure why I needed SSL in the first place.

Once plagger was installed there isn't a terribly large amount of info about how to set it up. You basically have to create a config.yaml file in the same directory as the plagger executable or create a yaml file with any name and specify the location with the -c flag.

The yaml files configuration are easy to read but what options are available for each plugin is a bit obtuse without any examples to look at. There are some but it took me a while to find them since they aren't listed on the plagger cookbook which is linked to from the homepage. To find out what options are available to each plugin you'll either need to read the examples or the bottom of the plugin's source code files to get a description of what it does and it's options. I'm also not sure what all of the types of plugins do but I gather than Subsription plugins are plugins for reading RSS feeds and incoming data, Publish plugins are for publishing RSS feeds, email, html etc., and Filters are for parsing and/or modifying the data.

I used three Plugins to achieve what I wanted to do which was to get e-mail sent to my gmail account and my mobile. I used the Subscription::Config, Filter::HTMLScrubber, and Publish::Gmail plugins. The config plugin pulls from an rss feed and caches the results. It only passes on changes to the feed to other plugins. The Gmail plugin is essentially a SMTP/SMTP TLS plugin which sends e-mails when it gets updates from the subscription plugins. Unfortunately the version of the plugin that installed with cpan had a bug as it called the MIME::Lite::extract_addrs function which is not present on the machine where I was running plagger. I needed to update the Gmail.pm plugin file to the newest version in plagger's svn. That version includes a fix around like 214 to call the extract_full_addrs fuction if the extract_addrs fuction doesn't exist.

Next, my mobile doesn't support html mail very well so I had to scrub the HTML from the RSS feeds with the HTMLScrubber plugin. Unfortunately though the Gmail plugin sends e-mails as text/html encoded so I needed to further modify the Gmail.pm file to mail as text/plain around line 90.

After that the template file that is used to generate the e-mail, gmail_notify.tt, was missing so I needed to get that from svn as well and I put it in my .cpan/assets/common directory and added that directory to the templates search path in my config.yaml. The contents of the template are also html so I needed to edit the template to remove all the html tags.

After that I just put config.yaml in the same directory as my plagger executable and added a line to execute plagger every 10 minutes to my crontab. This also had it's glitches as plagger prints debug and info messages to stderr so you can't just do "plagger > /dev/null" you have to have something like "plagger > /dev/null 2>&1" so that cron doesn't email you with plagger info messages every 10 minutes.

Anyway, after a few hours of messing with it, it finally worked. Here is the config.yaml I used.

global:
  assets_path: /home/<myuser>/.cpan/assets
plugins:
  - module: Subscription::Config
    config:
      - feed:
        url: http://IanMLewis:<twitterpassword>@twitter.com/statuses/replies.rss

  - module: Filter::HTMLScrubber
    config:
      comment: 0

  - module: Publish::Gmail
    config:
      mailto:   <me>@gmail.com, <mobile e-mail>
      mailfrom: twitter@ianlewis.org
      mailroute:
        via: smtp
        host: localhost:26
        username: <local mail user>
        password: <local mail password>