This tutorial assumes that you:

  • Know what Tracks is, and have successfully installed it
  • Know your way around a shell account
  • Are familiar with the Dreamhost web panel
  • Know how to use phpMyAdmin (for todomail.pl only)

If you do not have these prerequisites, you are not going to have much luck following this tutorial!

  1. Create a new shell user at the Users panel. Do not assign it the e-mail address you want to send Tracks items to. This is the first step because it takes a few minutes to process.
  2. 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.
  3. Log in as your own shell user, and use perl -M<module> to determine if the required Perl modules for your chosen script are present. If not, follow these instructions to install them from CPAN.
  4. In a separate window, login as your new shell user, and run pine. When it comes up, note the HOST it prompts you to log into. This should be something.dreamhost.com – mine was spork but yours may be different.
  5. In the Manage Email panel, create a new forwarding address. This is the address you will be sending Tracks items to. Forward it to yourshelluser@yourmailhost.dreamhost.com.
  6. In your new shell user’s root directory, create .forward.postfix and .procmailrc using the file contents below; make sure you fill in the appropriate variables. Also create the .procmail directory to hold logs.
  7. Modify the script you are using according to the variables below, and upload it.
    • If you are using sms_todo.pl, make sure you modify the DBI->connect line as shown in the example below – if you don’t, it assumes you are connecting to localhost, which Dreamhost doesn’t allow. Additionally, make sure you tell the .procmailrc file to send to sms_todo.pl – the example below uses the other script.
    • If you are using todomail.pl, go into your Tracks installation and create a context to receive the emailed actions. Check that context’s ID in phpMyAdmin.
    • Note that both scripts declare the port as 3000 – you can safely ignore this.
    • Find your Tracks password hash by referring to your RSS feeds page. It’s that big long random string in each feed.
  8. Send yourself a test email by issuing the following as your usual shell account: echo "test" | mail -s "add actions using email" youralias@yourdomain.com
  9. After a few moments, check your Tracks screen to see if the new item is there. If not, go to your new shell user’s account and open up the .procmail/log file. At the bottom you will see whatever error messages were raised; you’re mostly on your own for correcting them but they are pretty user-friendly.

Here’s the code you need:

.forward.postfix

“|/usr/bin/procmail”

.procmailrc

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log
SHELL=/bin/sh
# from email to tracks
:0
* ^To.*(YOURALIAS@YOURDOMAIN.COM)
| /usr/bin/perl -w /home/USERNAME/YOURTRACKSLOCATION/todomail.pl

todomail.pl

#!/usr/bin/perl -w

use strict;
use lib ‘/home/USERNAME/perlmods/share/perl/5.8.4/’;
use Frontier::Client;
use Email::Filter;

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

# Define the host first.
my $HOST = ‘YOURTRACKSLOCATION.COM‘;

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

my $client = new Frontier::Client(url => ‘http://YOURTRACKSLOCATION.COM/backend/api’);

# Replace with your username/password
my $username = ‘TRACKSLOGIN‘;

# 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 = ‘TRACKSPASSWORD‘;

# 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 tasks by email
my $context_id = ‘ID‘;
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.