WordPress.org

Ready to get started?Download WordPress

Forums

blogging by e-mail: do you have it working? (14 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    are you able to blog by e-mail? If so, do you have any tips on getting it working? Specifically, how do you get WP to check the mail server for that specially formatted e-mail you send in?
    I wrote a cron job that just does "php wp-mail.php" but this craps out with a complaint that my server isn't RFC-1939 compliant, whatever that means. I'm running sendmail and Apache, hardly non-standard stuff.
    it would be great to get this working...

  2. Kitten
    Member
    Posted 10 years ago #

    try using wget and request "wp-mail.php" via HTTP. /dev/null the output, and you should be good.

  3. carthik
    Member
    Posted 10 years ago #

    or you can use GET ">http://example.com/wordpress/wp-mail.php` in the cronjob.

  4. Anonymous
    Unregistered
    Posted 10 years ago #

    2fargon, thx for the additional info. I'm still confused, however. what type of file am I putting that GET command into? and how to execute it?
    thx

  5. carthik
    Member
    Posted 10 years ago #

    on your shell access (ssh) command line, type crontab -e to edit the crontab, that is, to add a new cron task. The command I referenced above is the command in the new cron job that you will create.
    Googling for "scheduling jobs using cron" will get you there :)

  6. midtoad
    Member
    Posted 10 years ago #

    Hey! nobody told me I'd have to use vi to get this going! (ever notice that 'vi' are the first two letters in the word 'vile'? )
    Anwyay I created a crontab command:
    15,30,45,0 * * * * GET http://midtoad.homelinux.org/wp/wp-mail.php
    It's running every fifteen minutes, but the output is the following:
    Can't locate object method "init_header" via package "HTTP::Headers" (perhaps you forgot to load "HTTP::Headers"?) at /usr/lib/perl5/site_perl/5.6.0/HTTP/Message.pm line 189
    Does that look at all familiar?

  7. carthik
    Member
    Posted 10 years ago #

    Yo midtoad, seems like it's not quite working out for you yet. I tried the url for wp-mail.php you have given above in my browser and it gives me a not-compliant error. You should find a solution for that first.

  8. midtoad
    Member
    Posted 10 years ago #

    There appears to be a bug in the file class-pop3.php, so that it returns the wrong answer when provided by the +OK status that a NOOP request makes. This was apparently found as far back as September 2003, when WP was b2, and the bug has been carried forward. Read this post (which I found out about on Google).

  9. midtoad
    Member
    Posted 10 years ago #

    After fixing the above bug, I see a couple of things that are needed to make this work. (after I get this all worked out, a Tutorial might be in order).
    In the Options settings, the user and ID to set are those for the account where you will send the messages that contain your posts. In the first line of the message itself, you have to enter a userID:password, and this should be for a user that has permission to post on your blog (let's call it 'email'). I recommend setting up a separate user just for mobile postings, since the userID and pwd are transmitted in clear-text in the message.
    After sorting out all of the above, I got success! (sort of). When I open wp-mail.php script in a browser, or run "php wp-mail.php" in a shell prompt, I see that the latest message in the 'email' account has been processed by the script, that the user ID and password, as well as the subject and contents of the message were extracted, and that the script also deleted the message - good, that way the account is self-flushing.
    However, the script also writes SQL to insert the latest message into the WP database, and this SQL has an error in it:
    [You have an error in your SQL syntax near ')' at line 1]
    INSERT INTO wp_posts (post_author, post_date, post_content, post_title, post_category) VALUES (3, '2004-05-07 16:25:02', 'First post by e-mail! This means that I can now blog from just about anywhere there is internet coverage or cellular coverage. Great!', 'First post by e-mail!', )
    I suspect that the trailing comma might be the error, and will investigate.

  10. midtoad
    Member
    Posted 10 years ago #

    Hey! that didn't take long. The damn thing works!
    Using phpMyAdmin (anyone reading this that is not already using this fantastic tool, get it NOW!), I posted the erroneous SQL into the SQL window for the wp_post table. I was immediately able to see that it was not the trailing comma <i>per se</i> that was the problem, but the missing post category that should come after it.
    Now here's the rub. The wp-mail script as it stands is not set up to parse out a category. So what to do? The easiest thing, though a bit of a kludge, is to edit the wp-mail script so that it writes a category into the SQL. But what category? 'General' would be a good idea. Or maybe one could create a new 'mobile' category and write out its category number (check the database for that). I'm going with the former.
    You can see the first mobile post on my site, here .

  11. midtoad
    Member
    Posted 10 years ago #

    Ok, I changed my mind on how to deal with categories. I'm trying to debug the wp-mail.php script (maybe I should take this discussion over to the dev area) and I see a problem: it looks for the category from the content of the mail message using a function called xmlrpc_getpostcategory($content). I'll have to track that down and see how it does it.
    Here's an excerpt from the wp-mail.php script:

    if ($user_level > 0) {
    $post_title = xmlrpc_getposttitle($content);
    $post_categories[] = xmlrpc_getpostcategory($content);
    if ($post_title == '') {
    $post_title = $subject;
    }
    if (empty($post_categories)) {
    $post_categories[] = $default_category;
    }
    if (!$thisisforfunonly) {
    $post_title = addslashes(trim($post_title));
    $content = preg_replace("|\n([^\n])|", " $1", $content);
    $content = addslashes(trim($content));
    if($flat > 500) {
    $sql = "INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category) VALUES ($post_author, '$post_date', '$content', '$post_title', $post_category)";
    } else {
    $sql = "INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category, post_lat, post_lon) VALUES ($post_author, '$post_date', '$content', '$post_title', $post_category, $flat, $flon)";
    }

    FYI all of this. I can't work on this any more for a day or two...

  12. TechGnome
    Moderator
    Posted 10 years ago #

    I don't know about the version you are using, but in mine, in the blog by mail options area, there was supposed to be a drop down to select the default category for these posts. I wonder if adding sub cats has caused this to go wonky.
    TG

  13. carthik
    Member
    Posted 10 years ago #

    midtoad, good work! Please keep up posted on how it works out.

  14. Anonymous
    Unregistered
    Posted 9 years ago #

    any update?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.