Synchronize IMAP accounts outside the main mailbox

Sep 06, '02 09:01:30AM

Contributed by: genecutl

As far as I can tell, there's no way to get Apple Mail to automatically check for new mail in IMAP mailboxes besides the main mailbox. You can do this manually by choosing 'Synchronize Account' under the Mailbox menu, but who wants to do things manually?

I was hoping the new version of Mail with 10.2 would fix this, but it didn't, so here's my solution.

Save this little shell script below as an executable after entering the name(s) of your IMAP account(s) into the code:

#!/bin/bash

# replace "account1", etc., with the names
# of your imap accounts
accounts=(account1 account2 account3)

for acct in ${accounts[@]}; do
/usr/bin/osascript <<EOF
tell application "Mail"
synchronize with imap account "$acct"
end tell
EOF
done
If you're not comfortable with the Terminal, you can do it like this. In the terminal, type
cat > ~/synchronize_imap.sh
Paste in the script text from above, then press control-D. After that, type
chmod 744 ~/synchronize_imap.sh
Then you need to tell cron to execute this script on a regular basis. I chose to check every 5 minutes. Here is how to edit your crontab manually using emacs. In the terminal type:
set EDITOR emacs
crontab -e
In the window which opens, paste in this text, changing [user] to your user name:
*/5  *  *  *  *   [user]    ~/synchronize_imap.sh
Press control-X, control-C to save and exit the editor. Alternatively, I believe there are some GUI apps to configure cron (such as Cronnix).

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2002090606013080