WP-keitai-mail Plugin v. 1.0

Finally got around to writing some kind of doc for my mail posting script for WordPress. And I can therefore finally release it for the world to use and enjoy.

Please welcome a new member in the WP plugin & hack family: wp-keitaimail v. 1.0b!

Actually, it is not technically a plugin, nor a hack, rather a standalone script that interfaces with WP to let you post entries to your blog via Email.
The name ‘keitai’ simply means ‘cell phone’ in Japanese… This script might as well have been called wp-cellphone-mail, I just liked the sound of ‘keitai’.

You can see a working demo on the right-hand side of this blog where it powers the “keitai log”. I have been using it for nearly a month now and it should be really stable albeit a tad complicated to set up (see below).

A quick roundabouts of the current features:

  • works as a script executed on email reception (unlike WP’s built-in feature), which means you do not have to run a cron job and your posts appear instantaneously on your blog.
  • handles jpeg pictures, will automatically create a thumbnail if they are too big and insert all necessary code in your post.
  • can be run on a separate machine from your WP install: it uses xmlrpc to post the entry and can be set to use ftp to upload the picture files.
  • can handle as many blogs and authors as you want. For each email account you can customize any aspect of the posts (image formatting, posting category etc). For example, you can easily set up the script to let 5 authors post to your blog with each one under a different category.

Now for the bad news:
This script is not trivial to set up. I have tried to include very detailed instructions that should supposedly be enough for even non technical-minded people. But hooking up the script to the email address can be somewhat complicated, and more importantly, it heavily depends on each hosting solution… which makes it quite hard to document.
Overall, you should be fine if you have ONE of the following:

  • A “mail forward” feature in your server control panel (especially if the control panel in question uses the very common ‘cpanel’ solution) that lets you forward mails to a script (it usually does).
  • OR

  • a file entitled .procmailrc in your server root (meaning your mail server uses procmail).
  • OR

  • an Exim recipe file. However, you will need to know how to edit it (or look it up online, it’s not that hard), since I haven’t had time to write instructions for Exim.

If you think you have one of these, check out the full instructions in keitai-prefs.php for details on hooking the script and set it to use your blog. I tried to be as clear as possible, but if you run into any problems using them, please let me know. You do not have to be a programmer or know anything about PHP to use this script, however, it is probably a good idea to hold on for now if you are not comfortable editing a settings file manually and tweaking around your server settings.

Hopefully, next release (date very much unknown) will make a lot of this easier.

In the meantime, if you wanna use this wonderful little toy, just download the archive here. Unzip it, edit the keitai-prefs.php file, following the detailed instructions it contains and upload the whole lot to your server. The script doesn’t need to be inside your web root (somewhere inside the ‘www’ or ‘public_html’ folders) since it is not accessed through the web, actually, it is preferable if it is not.

Among the features I plan to add for an hypothetical 1.2 version are:

  • Simpler interface to edit the script preferences
  • POP3 support (if you want to use it like WP’s built in script).
  • Password protection for posting.
  • Access to post settings through email commands (e.g. you could choose the category to post it to).
  • Support for more media types (movies, other graphic formats).
  • Support for GPS coordinates.
  • Full kanji support. Although this seems to be problem with the xmlrpc lib, the script has troubles with emails containing kanjis as of now. YMMV though.
  • as well as:

  • Support for EXIF data
  • Better cleaning of content: remove unnecessary new lines etc. (allow textile parsing?)

All that depending on the level of interest and the time I will be able to spend on it (not much for now). If you’d like to see other features or are having issue getting the script to work correctly, please let me know.

Enjoy!

Filed under: WordPress

88 comments

  1. It does have protection to limit the poster. You have to set it up to use “allowed” email addresses.

  2. Hi,

    I got the latest wordpress at this time so 1.5.
    The script doesn’t work because there is no class-xmlrpc.php but only a xmlrpc.php file in the wordpress dir. I changed the require_once in wp-keitai.php. It does’t make any errors but I only have a :

    Content-type:_text/html_/_/XML-RPC_server_accepts_POST_requests_only
    (extracted from the qmail logfile – current)

    What does it mean ?
    Thx
    Tom

    PS: I also don’t understand where the $enforce_senderl=true will find the “friendly emails” but for the moment it’s not really a matter because no mail appears in my blog 🙁

  3. Okay, i had a little trouble getting this working on 1.5.

    First of all i kept geting errors about class-xmlrpc.php being missing, solved this by getting the file(s) from WordPress 1.2.1.

    Then I kept getting an empty error, i was using my email client and i had only set the script to use my mobile.

    It’s now working fine, except that my mobile provider is sending the e-mails in html format (tables ‘n’ all), plus they’re including my phone number in the mail, and i can’t use my own subect, http://blog.7784.co.uk/you-have-received-a-new-message/ :O

  4. I have just one question… the script works great. No problems on my blog except that it seems to keep inserting breaks after a certain number of characters which makes it less wide than the space I have allocated. I can’t find where that happens. Could you point me in the right direction? I saw your post abt not supporting any more but I was hoping this would be a simple “look here bone head” kinda thing 🙂

    Thanks

    mbx

  5. For some reason when sending an email to the script there is no posting being done. I’ve checked all the categories and I check the file wp-keitaimail-prefs.php and everything seems to be configured the way it is supposed to.

    Any ideas?

    Suggestions?

  6. Hi,
    Great Script – but I am unable to get it to work. I am using a webhost who is providing interface thro cpanel – I guess I have followed most of your instructions – but on sending an email to that address – I get the following reply::

    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es) failed:

    pipe to |php /home/***/wp-keitaimail/wp-keitaimail.php
    generated by ***@ashwinkumar.net
    local delivery failed

    The following text was generated during the delivery attempt:

    —— pipe to |php /home/***/wp-keitaimail/wp-keitaimail.php
    generated by ***@ashwinkumar.net ——

    PHP: Error parsing /usr/local/lib/php.ini on line 272
    Turck MMCache requires Zend Engine API version 20021010.
    The Zend Engine API version 220040412 which is installed, is newer.
    Contact Dmitry Stogov at http://turck-mmcache.sourceforge.net for a later version of Turck MMCache.

    Status: 404
    Content-type: text/html
    X-Powered-By: PHP/5.0.3

    No input file specified.

    —— This is a copy of the message, including all the headers. ——

  7. Sorry for the previous post – I had not set the path correctly – Now I am having a different problem altogether – have posted the error message below

    —— pipe to |php /home/ashwinku/public_html/wp-keitaimail/wp-keitaimail.php
    generated by ***@ashwinkumar.net ——

    PHP: Error parsing /usr/local/lib/php.ini on line 272
    Turck MMCache requires Zend Engine API version 20021010.
    The Zend Engine API version 220040412 which is installed, is newer.
    Contact Dmitry Stogov at http://turck-mmcache.sourceforge.net for a later version of Turck MMCache.

    Content-type: text/html
    X-Powered-By: PHP/5.0.3

    Warning: main(/home/ashwinku/public_html/blog/wp-includes/class-xmlrpc.php) [function.main]: failed to open stream: No such file or directory in /home/ashwinku/public_html/wp-keitaimail/wp-keitaimail.php on line 31

    Fatal error: main() [function.require]: Failed opening required ‘/home/ashwinku/public_html/blog/wp-includes/class-xmlrpc.php’ (include_path=’/home/ashwinku/public_html/wp-keitaimail/:.:/usr/lib/php:/usr/local/lib/php’) in /home/ashwinku/public_html/wp-keitaimail/wp-keitaimail.php on line 31

    —— This is a copy of the message, including all the headers. ——

  8. Hi. I love this program.

    Let me leave some information for qmail users.
    -go to the root directory and find a .qmail-accountname file. Edit it like this,

    ./.panel/users/*youre-mailaccountname*/
    |/usr/local/bin/php /home/*yourdomein*/public_html/*yourdirectry*/wp-keitaimail/wp-keitaimail.php

  9. Hi, Dr. Dave.
    If you don’t mind, may I ask how to set up the latest updated pictures on the sidebar like your blog?

    I just like to show several thumbnaills and link to the post that has the picture.

  10. Gogh:
    Magic of PHP… Hasn’t got anything to do with wp-keitai-mail, all custom PHP code that fetches the posts and cull them in this sort… When I have a sec, I might release such a theme one day… don’t hold your breath though (bit busy these days).

  11. Hi, Dr. Dave.

    Is it possible to post images as excerpt via keitai? I mean I like to put an attached image into the excerpt form.

    The reason is that there is a plugin that generates thumbails from excerpt fields and display them randomly.

    If it takes a lot of work for you, please never mind. 🙂

  12. Cool script!

    A nice feature would be to be able to call the script using Cron, and it would poll a specified POP account for mail and insert into the blog.

    That would make the script much easier to implement for people without an own mail server.

    Great job though!

  13. Pingback: JonCellini.com
  14. Has anyone used this successfully with PHP5? I seem to be hitting a bug in mimedecode.php that causes the script to throw:

    “Fatal error: Using $this when not in object context”

    It looks like this is fixed in mimedecode.php 1.40 or greater but I’m still not having luck. If anyone has suggestions I’d be appreciative.

  15. I found a solution 🙂

    It looks like the syntax for calling mimedecode.php has changed in PHP 5.x, so a slight tweek to the wp-keitaimail.php was all that was needed to get it working again.

    I’ll drop Dr. Dave an email with the fix.

  16. I installed the script and sent a few messages – it works nice 🙂 but I’ve got a problem with Polish characters such as ó ę ź ć etc. There are some incorrect letters displayed instead. I tried setting up UTF-8 and some other encodings in the Thunderbird, but it didn’t help. Is there any solution for this?

  17. What is the exact command line I have to use, while connected through SSH to my acount, to forward an e-mail address (example at exampledomain dot com) to a file in my hosting account exampledomain.com/wpblog/content/file.php

    Thanks in advance.

  18. Juanfer, there’s no way for any of us to know what the exact command line you have to use is. Please contact your hosting provider for assistance.

  19. Hello,

    How can we improve the script to manage category… I would like usage like
    subject of the mail : [category]Title of the article
    mail : article

    idea?
    Pascal

Comments are closed.