First off, I have to confess that unless you already know what you’re doing, this is a pretty technical trick.
I have rigged my hosted Tracks installation to be able to receive emails into an Inbox context I can sort through later.
This allows me to go through my email (gmail, or otherwise) and forward emails to “mygtd@mydomain.com” and have it automatically create a to-do with the subject of the email as the description and the body of the email as a note.
Again, this is somewhat tricky, but if you have the background to do it, I am including source code. In this case, all we have used is a perl script.
I can provide very little support, so hopefully you can get it working. This is something I badly wanted, and found a way to do… I didn’t think I should hoarde the benefits to myself, but neither can I be as much assistance as I would like.
Requirements:
I. You have to run your own email server capable of receiving emails and piping it to a script. If you don’t know what this means, you may not be able to do it.
II. You probably have to be running Tracks in a hosted environment. I have not tried it with anything other than on a linux host.
Once you have created the email address, modify the following script per the comments, and pipe it to the script. It works wonderfully.
#!/usr/bin/perl
# Quick and dirty hack to add tasks via an email.
# Install by adding an alias in /etc/aliases or /etc/valiases depending
# on yor system:
#
# mygtdaddress@mydomain.com: "|/home/directory/inboxgtd.pl"
#
use strict;
use WWW::Curl::Easy;
open (STDOUT, ">/dev/null"); # Redirect CURL output to null. Some mail servers will bounce
open (STDERR, ">/dev/null"); # messages if there is any return.
# Replace with todos.xml url of your GTD installation
# my $url = "http://yourgtd.yourdomain.com/todos.xml";
my $url = "http://yourgtd.yourdomain.com/todos.xml";
# The contextid where you want the todo added. Usually an inbox.
my $contextid = "1";
my $curl = WWW::Curl::Easy->new();
my $description = "";
my $note = "";
# Your authorization credentials in the format
# my $auth = "username:password";
#
my $auth = "username:password";
# Leave these tokens alone. They are valid as of Tracks 1.5 RESTful API.
my $notetag = "todo[notes]";
my $contexttag = "todo[context_id]";
my $descriptiontag = "todo[description]";
# Dirty hack. First blank line begins body text.
my $passedempty = 0;
my @mail = <STDIN>; # Read in the piped email
my $line = "";
foreach $line (@mail)
{
if ( ($line =~ m/Subject: (.*)/) ) # If it's the subject line...
{
$description = $1; # ... use it for the todo description
}
if ( $line =~ m/^$/ ) # Checking for that blank line
{
$passedempty = 1;
}
if ($passedempty) # Once we see it ...
{
$note = $note . $line; # Copy every blank line into the todo note.
}
}
# Here we munge the data together to post.
my $post_data = $contexttag . "=" . $contextid . "&" . $descriptiontag . "=" . $description . "&" . $notetag . "=" . $note;
# We execute curl to do the posting.
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_POSTFIELDS, $post_data);
$curl->setopt(CURLOPT_USERPWD, $auth);
$curl->perform();
close STDOUT;
close STDERR;
