Email – Tracks integration

I’m wating for an enhancement to Tracks in order to be able to send an action to Tracks using email. I’m not a Ruby programmer, so I’ve made a solution for myself while hoping for a permanent solution from the Tracks project.

I made the following script, based on the perl script by Russell Harrison:

#!/usr/bin/perl -w

use strict;
use Frontier::Client;
use Email::Filter;

# read email from stdin
my $mail = Email::Filter->new();

# Define the host first.
my $HOST = 'localhost';

my $PORT = '3000';
# Now we create the client object that will be used throughout the session.

my $client = new Frontier::Client(url => "http://$HOST:$PORT/backend/api");

# Replace with your username/password
my $username = "XXXX";

# you can get the value for your password by doing a query against the db
# select login,word from users where login like "username"; Or check the
# URL's in the feed section.
my $token = "XXXX";

# To get the context_id (a number!):
# select id,name from contexts where name like "context_name";
# I've created an @inbox context for receiving tast per email
my $context_id = "99";
my $description = $mail->subject();

# now make the request to tracks and add your task
my $request = $client->call('NewTodo', $username, $token, $context_id, $description);

# All you need to do is modify the script to take arguments and perhaps
# look up the actual values in the db for you.

In Sendmail you need to make an alias so that Sendmail will process an incoming email to that alias using the script. On Fedora Core, add this to your /etc/aliasses:

myalias: "|/usr/bin/perl -w /path/to/todomail.pl",backupbox

This will process all email tot myalias@your.domain.com using the script todomail.pl. It will also put a copy in backupbox@your.domain.com if you want a backup of the email. Of course backupbox needs to be an existing email box. Tell sendmail about the new alias by executing newalias.

Next, you have to allow Sendmail to execute your script. By default, for security reasons, Sendmail cannot execute anything. Try:

ln -s /usr/bin/perl /etc/smrsh/

And restart Sendmail. Test this by sending an email to myalias@your.domain.com:

echo "test" | mail -s "add actions using email" myalias@your.domain.com

If all goes well, you’ll see a new action in Tracks in de context you configured in the script. Also the backupbox should contain a copy of your email. If somthing does not go wel, look for error messages in the email that got sent back. Also /var/log/maillog could contain error messages.

UPDATE: It was very easy to add the option to the api to add notes to the todo that is created. See this post.
Remark : By default Fedora Core does not have the libraries for Frontier::Client and Email::Filter. I’ve got those from CPAN. To install:

From the root prompt on your server, invoke the CPAN shell:

perl -MCPAN -e shell

Once the Perl interpreter has loaded (and been configured), you can install modules by issuing the command install MODULENAME.

The first thing you should do is upgrade your CPAN:

cpan> install Bundle::CPAN

Once it’s done, type:

cpan> reload cpan

Now, enter the following command to retrieve all of the required modules:

cpan> install Frontier:RPC2 cpan> install Email::Filter

Explore posts in the same categories: GTD, Life, Server, Tools

One Comment on “Email – Tracks integration”

  1. Amanita.net » Blog Archive » Making Email-to-Tracks Work on DreamHost Says:

    [...] Download your preferred script – either todomail.pl or sms_todo.pl. I have only provided code modifications for todomail.pl but if you prefer to use sms_todo.pl you should be able to figure out what needs to be changed. [...]

Comment:

Powered by WP Hashcash