hm-mail-gateway

Simple mail-to-braindump filter for Hiveminder. Designed to be used in as a pipe command from an aliases file; may also work in a procmail setup, but I haven't tested that. At some point I'll package this up in an actual module and put on CPAN but so far I've spent about two hours on it and it works Good Enough For Me(tm), so it may be Good Enough For You Too.

You can check out the script via anonymous SVN by running svn co svn://genehack.net/hm-mail-gateway/trunk ./hm-mail-gateway

In addition to the ability to modify your mail aliases file, requires several Perl modules:

  • Email::MIME
  • Email::Send
  • Net::Hiveminder
  • YAML

(If you don't know what 'modify your mail aliases file' means, this probably isn't going to be too useful for you.)

Extremely rough INSTALL

You'll need a configuration file -- call it hmgw.yaml and place it in the same directory as the script. (If you don't like the file name, there's a single line in the script you need to change; it's early in the file and commented.)

The config file should look basically like this:

---
email: HIVEMINDER LOGIN
password: HIVEMINDER PASSWORD
report: ADDRESS TO MAIL PROBLEM REPORTS TO
accept_from:
  - EMAIL ADDRESS 1
  - EMAIL ADDRESS 2

It is a YAML file, so the leading three dashes are important. It needs to be no more more than mode 0600 and therefore obviously owned by the appropriate user.

Mail that doesn't have a From: line that matches one of the accept_from addresses will not generate a task, and will cause a mail to be sent to the report address. The accept_from addresses are matched via regular expression; they don't have to be exact literal strings. The script matches against the header From:, not the envelope From, so it is possible for somebody to generate tasks by forging mail in the right way. Making the mail alias something that isn't a dictionary word is probably a good idea if your spam load is anything like mine. Also probably not a good idea to share that address.

If you want all tasks created via this filter to have a default tag, add a line to the config that looks like:

default_tag: DEFAULT TAG

Finally, to hook it up, add an entry to your mail aliases file (/etc/mail/aliases for me; probably something different for you) that looks like this:

hm-gateway       "|/path/to/hmgw.pl"

Run newaliases (or do whatever dance you do to regenerate the aliases database), and you should be in business.

When creating tasks, the Subject: is used as the task summary for the newly created tasks. Anything in the body of the message will end up in the 'Notes' field of the task. If everything works okay, you'll get an email back to the address that sent the mail to create the task; it will contain a link back to the task on the Hiveminder site.

Comments, bug reports, etc. can be sent to genehack at genehack dot net.