Published in the IETF Journal
Published in the IETF Journal
This is for those folk in google land querying for “applescript make new mailbox Imap”
Today I finished my first applescript. Using components from several other scripts I set out on the following task.
One of the subtasks is to build the mailboxes in IMAP with these directory structures. Taking an existing example (The MailArchiveByDate scropt from Dough Hellman) I first took a left to right approach. Writing out what happens internally in a test script would look like:
— Emulating what would happen in the code loop:
make at the end of the mailboxes of account (name of theAccount) new mailbox with properties {name:(“ArchiveRepository”)}
make at the end of the mailboxes of account (name of theAccount) new mailbox with properties {name:(“ArchiveRepository/domain.of.list”)}
make at the end of the mailboxes of account (name of theAccount) new mailbox with properties {name:(“ArchiveRepository/domain.of.list/listname”)}
— etc etc
In Doug’s code functionality is achieved by:
— Find the month archive mailbox. If this does not
— exist, we create it.
try
set monthMailbox to (mailbox archiveMonth of yearMailbox)
on error
log “Creating ” & archiveMonth & ” mailbox”
if imapAccountName is “” then
make new mailbox with properties {name:mailboxName}
else
make at the end of the mailboxes of account imapAccountName new mailbox with properties {name:mailboxName}
end if
set monthMailbox to (mailbox archiveMonth of yearMailbox)
end try
Unfortunately this does not seem to be portable to all IMAP servers. My email server generates an error when I try to CREATE “ArchiveRepository/domain.of.list” while “ArchiveRepository” already exists and is not a container of other mailboxes.
The obvious solution is create the mailbox using the full path, all the way to the last mailbox that will not be a container of mailboxes but of messages. An example is below:
try
set rootMailbox to mailbox ArchiveRoot of theAccount
on error
display dialog “Creating ” & mailboxName & ” mailbox in ” & name of theAccount with icon 1
make at the end of the mailboxes of account (name of theAccount) new mailbox with properties {name:(mailboxName)}
set rootMailbox to mailbox ArchiveRoot of theAccount
end try
set ListDomainBox to my ReturnChildMailbox(rootMailbox, TheDomain, theAccount, mailboxName)
set ListnameBox to my ReturnChildMailbox(ListDomainBox, TheListName, theAccount, mailboxName)
set YearBox to my ReturnChildMailbox(ListnameBox, archiveYear, theAccount, mailboxName)
set QuarterBox to my ReturnChildMailbox(YearBox, Quarter, theAccount, mailboxName)
log “Box set to ” & name of QuarterBox as text move theMessage to QuarterBox
Where ReturnChildMailbox does the appropriate creation
on ReturnChildMailbox(ParentMailbox, childname, theAccount, FullPath)
tell application “Mail”
try
set ChildMailbox to (mailbox childname of ParentMailbox)
on error
display dialog “Creating ” & childname & ” mailbox in ” & name of ParentMailbox & return & FullPath with icon note
make at the end of the mailboxes of account (name of theAccount) new mailbox with properties {name:(FullPath)}
set ChildMailbox to (mailbox childname of ParentMailbox)
end try
end tellreturn ChildMailbox
end ReturnChildMailbox
Maybe I’ll post the script at some point 😉
This is for those folk in google land querying for "hpss Unable to bind to socket"
I am running a tiny appliance that is configured with Voyage linux. Its my always-on box that runs as web, mail, print, and file server. Between a update or two printing stopped working. A few minutes of investigation told me that something went wrong when starting /etc/init.d/hplip. It generated the following error:
Nov 3 19:22:39 tiny hpiod: 1.6.10 accepting connections at 2208…
Nov 3 19:22:40 tiny python: hpssd[24441] error: Server exited with error: Unable to bind to socket
Reinstalling cupsys, hplip, and foomatic did not fix this problem.
It took me quite a while to figure out what was wrong: localhost did not resolve to 127.0.0.1. The reasons for this are manyfold but boil down to the fact that I try not to mess with the default configuration to much and that that default configuration happens to create an /etc/resolv.conf that points to opendns resolvers. Those do not resolve localhost to 127.0.0.1 but to their web-traffic-magnet address.
The fix: make sure that /etc/hosts existed with a mapping from 127.0.0.1 to localhost