Support » Fixing WordPress » Why bother with cron for ‘post by email?’ Why not script it?

  • I’m no hardcore programmer, but why does everyone bother with setting up cron jobs? I haven’t done one myself, but I’ve read threads from several people who sounded frustrated.
    Why don’t people simply put something like “<?php include (‘./wp-mail.php’); ?>” in the first few lines of “index.php” to force the page to check for new emails EVERY time the page was accessed? I know it would take the page a little longer to load, but wouldn’t it be a marginal cost, considering how many people seem flustered when attempting to set op a cron job? (Maybe you could set a time stamp in a small “timestamp.DAT” file or something to only run it if it has not been run in a specified time period?)
    Wouldn’t that work? Just wondering. Like I said, I’m no programmer myself, so maybe there’s something I’m not thinking of.
    Please email me if this wouldn’t work, I’m really curious…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter loneboat

    (@loneboat)

    Anyone?

    I think some people like to think cron = ubergeek, esp when dropping it into conversations 🙂

    cron is easy when you know how, but if you don’t want to learn it then there’s nothing wrong with alternative solutions (apart from the small performance issues)

    The real problem is that wp-mail.php outputs stuff, which means that without modification it is inappropriate to include directly in a core WP file — at least on which regular users will be hitting.

    If you want to do this (avoid cron), you’d need to edit wp-mail.php. For most folks, setting up a cron job is easier.

    Thread Starter loneboat

    (@loneboat)

    I’m using a third-party host (goDaddy.com). Do commercial hosts typically allow someone to set up a chron job?

    For those without a dedicated cron facility, my WP-Cron plugin might help.

    As stated above, though, wp-mail.php by itself won’t work well, since it outputs directly to the browser. So I quickly hacked it to store messages in a log variable which is emailed to the blog admin at the end of the script (whether due to error, or successful completion). This is completely untested, as I don’t do blog-by-email (nor POP3 for that matter).

    wp-cron-mail.php

    what’s the story, loneboat?

    i tried entering that script into the first few lines wp-content/index.php, and when i surf to my blogsite, it accesses email, however, i also get: Author =
    Content-type: text/plain, boundary:

    Raw content:

    — test

    Author: 1

    Posted title: test
    Posted content:

    — test

    Mission complete, message 1 deleted.

    it posts all the data that shows up on the browser when i surf to /wp-mail.php

    i would like to be able to see just the content of the email and the subject; just the text you get on the blog when you run wp-mail.php

    do you know how i could do this?

    thanx for your response in advance.

    ed

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Why bother with cron for ‘post by email?’ Why not script it?’ is closed to new replies.