Mail Scripting Hooks?
September 8, 2005 6:35 PM   Subscribe

Can I hook a script onto the 'Get Mail' button/function in Apple's Mail.app in OS X Tiger?

I run my own IMAP server on a Linux machine in my house. It consolidates mail from POP sources with fetchmail. So I'd really like the 'Get Mail' button to first do 'ssh imap.server fetchmail' before it actually checks for new mail. (The machines are set up so that that ssh command works fine with key-based authentication to awaken the fetchmail daemon).
posted by teece to Computers & Internet (7 answers total)
 
I think you'll find it difficult or impossible to do it that way.

I have a similar setup, but I just have fetchmail running periodically (every few minutes) -- any reason why you can't do that?
posted by xil at 6:43 PM on September 8, 2005


Response by poster: I already have it doing that, xil, but when somebody sends me something that I need to check for right away, I have to open up Terminal.app and execute the command above. fetchmail is checking mail every couple of minutes, I think, but it just seems impolite to have it poll my ISP's server every 45 seconds or something.

It's just a bit of a hassle.
posted by teece at 6:47 PM on September 8, 2005


You could do with a bit of hackery (Mach Inject/HAXIE/Rogue Input Manager) but it wouldn't be pretty and might break between versions.

Mail.app deos have a plugin interface (PGP uses it among others) so you might be able to write a plugin for it - but apple hasn't publically distributed (AFAIK) the plugin interface.

It might be easier to just create an applescript to do it and plop it in the scripts menu. Not as convenient as overload the Get Mail button but easier.
posted by schwa at 7:27 PM on September 8, 2005


Best answer: I'd set the trigger up on the system. When IMAP syncs up, check if the POP boxes have been checked in the last, say, 30 seconds. If they have, don't do anything. If they haven't, poll them again.

Linux is a hell of a lot more scriptable than MacOSX apps, and depending on your POP3 server/(mailhandler if they're integrated), it really shouldn't be that difficult.
posted by devilsbrigade at 9:07 PM on September 8, 2005


Best answer: This is supereasy to do with Automator, although you can't connect it to the "Get Mail" button -- you have to invoke the Automator workflow some other way. You can save a workflow as an application or as a script that hangs off your global Scripts menu.

The actions you want in Automator are Automator:Run Shell Script and Mail:Get New Mail. The Save as Plug-in command lets you save the workflow in your Scripts menu, if that's how you want to invoke it.
posted by jjg at 9:46 PM on September 8, 2005


fetchmail is checking mail every couple of minutes, I think, but it just seems impolite to have it poll my ISP's server every 45 seconds or something.

Perhaps some more seasoned admins can comment, but I really don't think the ISP would care, as long as you're not doing something that looks like it could be an attack, which this clearly isn't. Mail servers are built to handle simple polling without any effort. It's only the actual moving of mail that creates notable load.
posted by mkultra at 8:51 AM on September 9, 2005


Response by poster: The Automator thing works, jjg. I'm going to have to start using that more.

I'm also going to look into doing it the way devilsbrigade mentioned, as that seems even more elegant.

Thanks.
posted by teece at 9:10 AM on September 9, 2005


« Older How to get a .gov domain name?   |   Why No Library WiFi? Newer »
This thread is closed to new comments.