2009-03-29

No More AppleScript

It's not that it's a bad language, but Mail just doesn't like to run them. I had this fairly simple AppleScript that ran the Perl script for each appropriate email, and it works if I click on an email and tell Mail to "Apply Rules", but it completely ignores the Rule, or heeds the rule but doesn't run the AppleScript, or runs the AppleScript and crashes without explanation - when processing an incoming email. I gave up. It's for the best anyway. Now I'm not bound to using a Mac, or needing Mail running.

And I turned to the Mail::IMAPClient Perl module.

I took the blogger script and added an imap checking component. It looks in a couple different mailboxes for emails with a certain subject and downloads them. The matching emails are cached locally and subsequent checks only look for emails after the date of the most recent cached email.

Then processing continues as normal - handing off a path to a "raw" email which eventually finds its way to the blog.

And all of this is tied together with OS X's version of cron (ie, launchd) with a little plist file.

--

I ordered 2GB of RAM for my Mac mini, which already performs the duties of a file and media server, webcam streaming server, VPN, BitTorrent client - and soon it'll be tasked with holding the Postgres/PostGIS database for Locator and doing all of this IMAP checking and blog posting. The original 512MB was never enough and the upgrade cost something like $20.

I'll probably spend three hours trying to figure out how to open the case.

2 comments:

  1. Right now... Curtis is here, with me! and Mikey and children and Bethy.

    ReplyDelete
  2. I should just make you a blog contributor....

    ReplyDelete