#!/usr/bin/ruby # you'll probably need your own ruby gems if you are running this on a shared host. # I did this approach: http://railstips.org/2008/11/25/rubygems-yours-mine-and-ours require 'net/pop' require 'rubygems' # if you do not have this installed just type 'gem install tmail' require 'tmail' # FILL OUT YOUR USERNAME AND PASSWORDS IN THS FILE CONFIG = YAML.load_file("./config.yml") #mail configuration mail = CONFIG['mail'] #tracks configuration tracks = CONFIG['tracks'] # important - this needs to be the path from this script # to the tracks_api_wrapper.rb # it is usually under YOURTRACKSINSTALL/doc/tracks_api_wrapper require tracks['api_wrapper'] Tracks::Base.site = "http://" + tracks['user'] +":"+ tracks['pass']+"@"+tracks['server'] default_context = Tracks::Context.find(:all).detect{|c| c.name == tracks[default_context]}.id #open each mail on the server pop = Net::POP3.new(mail['server']) pop.start(mail['user'],mail['pass']) pop.each_mail do |pop_mail| #parse the mail email = TMail::Mail.parse(pop_mail.pop) t = Tracks::Todo.new t.description = email.subject t.notes = email.body + "\nfrom: " + email.from.to_s t.context_id = default_context t.save #get rid of the email. pop_mail.delete end pop.finish