I wanted to do some post processing of email in a round robin manner where by all email going to sales@ would be evenly distributed among our sales team, in the past we had a line in /etc/aliases to process the sales@ messages as they arrived in, which I am aware we can still have. however I missed this during the initial migration, and had let the sales email queue pile up for a month. I had to come up with something quick for now, otherwise risk mutilation from the sales team. I had wanted to do a nifty ruby script which worked directly via SOAP, REST and or some other API however could not find anything which I could easily get working. So I started to dig into the utils and came up with the following shell script... it gets the inbox count size, builds a loop to process that inbox, and then evenly distributes those emails to whoever is in the agents array...
preqs for this script were the creation sub-folders in the targets inbox for the msg to be moved into (this can easliy removed to just delete the msg, but we wanted to have some idea of what was going where), and specifying of the agents, and target user account... in the future we will be going back to the /etc/aliases | option, since my shell script would favor those at the beginning of the array as time goes on. Also it writes the msg's to a local file temporarily which the zimbra user must have write access to, this file also could be considered a security risk as it could be monitored, so use at your own risk.. However for now it gets the job done... albeit very slowly... takes a couple seconds to process each message, however we have a low enough inbound that I can run this via crontab every 15 minutes and it does not have any problems.
Also I am looking to do some agent stats such as inbound and outbound counts daily for the sales agents any ideas in that regard would be appreciated.
See Next post for cleaner script.