Little background information: Will check a postgresql database if a site mail/message needs to be checked? It may be any site...a site like this escripts where programmers will leave messages, IMs, emails etc. and we need to get them, they may be sites like ebay, [url removed, login to view], any dating site..or many others where the user has an account which needs to be checked, fetched and deleted.
A cron script will run n times a day and spawn a bot. If a site needs its mail fetched, according to a schedule in the database, the bot will call a handler/fetcher bot built according to the site. This bot will login to the site, fetch all the messages in the site and delete them. All fetched messages will be stored as xml files in a directory specific to that site. After finishing with the fetching & deleting activity, it will pass a message to the invoking bot...you tell the method...system call, pipe, socket, file on disk which is checked by the parent bot periodically or something else.
Another bot is then invoked by the parent bot, which reads these xml messages and puts them into the postgresql database. This bot is a single bot that handles messages of different structures and handles them according to a xml-tag:fieldname:table type mapping. This mapping is stored in xml files & a corresponding mapping database, which can generate these files in case of a requirement to programmatically know the relationship between a xml-tag and a database record.
Post completion of uploading activity, the bot tells the parent bot of job completion and exits. Parent bot logs completion of a successful run & exits.
In all this, care has to be taken to handle system crashes, program crashes, multiple runs of the same bot etc. The bot has to have the signature of a web browser & execution is to be configurable and never harm the activity of the site being checked for mail/messages.
All communication in PMs please.