Monday, October 27, 2008

Set Up Email Automatic Polling


To automate the email polling and blog posting process in WordPress, you need to schedule a recurring task that loads the wp-mail.php script at fixed intervals (e.g., every five minutes). You need two tools for this: a lightweight URL loader called curl to load the PHP script, and the open source cron daemon to schedule the recurring URL loading tasks. Both cron and curl are installed by default on Linux, Unix, and Mac OS X computers. For Windows, you can install the Cygwin toolkit (http://www.cygwin.com/)to get a common set of Unix utilities including cron and curl.

You can use a fully featured web browser, such as Firefox, to load the wp-mail.php script every five minutes. But that is a huge waste of server resources.


Next, log into your server and type the following on the command line:

crontab e

This opens the cron control file, which contains all scheduled tasks, in the system's default text editor. You should append one line to the bottom of the file, save it, and exit the editor. cron automatically reloads the control file.

*/5 * * * * /usr/local/bin/curl http://yourdomain/wp-mail.php > /dev/null

The preceding line in the cron control file schedules the system to run the curl command in the last part of the line every five minutes in every year, month, week, and day. That's it! You now have a fully functional photo moblog server.

If you do not want to use the default editor, you can always export the cron control file to a text file, edit it externally, and then import the edited file back to crontab. See the crontab manual page for more information.

No comments: