JB's Blog

/au/SysAdmin

WP-Mail ver 0.311

with 34 comments

I had a nice long holiday at Coolangata, Queensland, Australia and had quite a lot of time sitting on the couch as my girlfriend read her book. So I grabbed my Powerbook and slowly worked away on my wp-mail.php plugin! It’s nice to work on something without having to worry about timing and just bang away…

IMG_259.jpg

And that’s a photo of my me lying on the couch, I knew I should have not taught Lauren how to use the camera… :)

Thanks to all the comments and feedback of this hack, because people submit code and fixes it’s a better program for everyone. With a little more work we’ll get this plugin rock steady stable and see if the wordpress dev team would consider it for the core code of wordpress.

Here’s the updates that have happened in the latest version:
- HTML e-mail support added (Thunderbird clients can easily use this mod now!)
- Subject line searching support for categories (i.e., Subject: [Code] WP-Mail, will post to the Code category)
- Added UBB decoding support, so if you want to post things written out of say phpbb you can now
- Direct posting support (using /etc/alias on your e-mail server you can send the
- PHP5 support
- More fixes

What needs to be done is a bit of work for the HTML e-mail support. It works at the moment, but it needs a little more work to add the images in position of where it is in the actual e-mail. At the moment all images in HTML e-mail’s are just attached to the bottom of the message which is probably not what people want. I can do it, just got to figure out the best way.

The second thing I suppose most people want is a little bit more image manipulation (like resizing images). I’m not sure if this should be included in wp-mail.php or have wp-mail.php interface with some other image plugin for WordPress. I’ve played around with thumb nailing

* -= History =-

* Version 0.311 – 2005-01
* – eep, major bug for pop3 server. Next time I test my code more before I released, fixed so that pop3 now works.
* Version 0.31 – 2004-12 & 2005-01
* (Has it been this long, best get back into the swing of things… did most of this coding on my holiday as I didn’t have a machine to play WoW on :)
* – moved the deletion of pop3 emails into a check so that e-mails aren’t deleted without proper checking.
* – added html ‘decoding’ (basic support for Thunderbird & Outlook)
* – updated the Category search so that it matches words as well as numbers (i.e. [General] Subjectname will work instead of just [1] Subjectname)
* – Changed time function from time to strtotime (as per Senior Pez’s suggestion), but found out that strtotime isn’t in default php distro…
*
* Vesion 0.3 – 2004-09
* – Added UBB decoding support
* – Added default title (when there is no subject assigned)
* – Started doing a little code cleanup, been reading Advanced PHP Book :)

Download it and test it out, I’ll be writing a little HowTo on using the direct e-mail support when I have a little spare time, in the meantime enjoy!

wp-mail-0.311.zip

Written by JohnBlade

January 31st, 2005 at 11:01 pm

Posted in Code

  • http://www.bloggie.com/wp/index.php?p=9 BSL/ESL » WP/MT/PM

    [...] nd got confused. I wiped out everything and uploaded version 1.5 instead. Turned out the Photo blogging plug-in only works in version 1.2. Yeah…that’s where I am right now. I swi [...]

  • http://www.bloggie.com/wp/index.php?p=9 BSL/ESL » WP/MT/PM

    [...] nd got confused. I wiped out everything and uploaded version 1.5 instead. Turned out the Photo blogging plug-in only works in version 1.2. Yeah…that’s where I am right now. I swi [...]

  • JohnBlade

    Sorry about the confusion with 0.31 not working with POP3, i was so excited aobut direct e-mail I didn’t check an update for pop3. It works properly now, let me know if you have any issues.

  • http://www.50d.net Olav

    Thanks a bunch, working smootly now! :)

  • Tom

    This is wicked – thanks very much for doing this.
    I set this up for my blog and the mail sending and checking via wp-mail.php seem to go fine, however, if I try to check my blog, I get the same post over and over and over again, even if it was only posted once.
    What’s up with that?

  • Golfy

    AWESOME plugin and exactly what I need :) It works GREAT too! I only have ONE problem :~ The category left blank and WordPress posted with funny error code on my blog (because there’s no category assigned)

  • Joel

    Mr. Blade, thank you thank you thank you. I just love emailing my blog posts. Strange thing is I can’t get the photo attachments to appear inline. I have the photo inline, but when I send and publish it the image is at the very end of the email (as what would happen when you just attached it to an email), and there’s a broken image where it was supposed to be. I use Thunderbird BTW.

  • http://denemea.sitemynet.com fatih

    nasil godum

  • http://theamells.net Ricardo

    I am having the same problem that the post is published without a category and without an author (even though the I’m sending the message from the WP user’s email)…

  • tom

    I solved the errors thing – just had to make sure to insert [General] before my mail subject line (is there a way to automatically set what category they’ll go into?) but my posts are being made without an author being listed, which is breaking the navigation in my blog.

  • http://www.jaynne.co.uk James

    This version is working great with WP 1.5 and PHP5. HTML email support is a bit buggy. I get a broken picture link where I put the picture and the pic is posted at the bottom. This was with using Thunderbird mail client in HTML mode. Plain text works great.

    I also get no author being posted despite the correct e-mail being in the from field. The option to default to a specified category would be good for when I forget to add it in myself

  • http://andper.net andper

    This is a great wp-mail substitute. I like it because it enables me to easily blog via my mobile phone. :)

    However, version 0.311 brings out 2 awkward bugs, already mentioned above. 1) Not specifying the default category, when category left blank in the subject and 2) not specifying the author id. The thing is, these two worked fine in v0.2.

    Tried fixing them myself but could only come up with _very_ amateurish solutions. Since I always use only one category for my ‘moblog’ posts, I commented out all the code between lines 144-167 except 152. And since I’m the only author of the posts, I modified line 180 to say 'post_author' => 1,.

    Hope someone comes up with better fixes. :)

  • http://theamells.net Ricardo

    I looked at the code a bit more and it looks like $poster is not being set. Tried to echo it out and got nothing…

  • http://www.alex101.net Alex

    Hi John,
    Can’t get it work.
    When I run it:
    http://www.alex101.net/wp/wp-mail.php
    It says everything is fine:
    But WP says:
    Warning: Invalid argument supplied for foreach() in /home/webadmin/alex101.net/html/wp/wp-includes/template-functions-category.php on line 65
    — @ 10:53 am Edit This
    This is the first post I’m creating from Email client in HTML format with
    picture attachment.

    xmlns:o=3D”urn:schemas-microsoft-com:office:office” =
    xmlns:w=3D”urn:schemas-microsoft-com:office:word” =
    xmlns=3D”http://www.w3.org/TR/REC-html40″>

    charset=3Dus-ascii”>

  • Chris

    I’m getting the same error when I don’t post a category. It goes away if you put [General] at the beginning of the subject line, but that’s kinda jenk, imho. This is a great plugin though, and although I’m no php expert, I think I can figure out in a few days how to make it automatically post to gerneral category if not specified. The email address checking feature is cool but bogus. I have like 5 different email addresses and want to be able to email to my blog no matter where I am. As it stands, I will only be able to email from work if I use a webmail client. Thanks for putting this out there though. I don’t mean to criticize, just giving my 2 cents in case you’re looking for feedback on how we’re using it.

  • athlon

    I have troble when use this program at chinese environment

    when I send mail by uuencode or base6 ,big5.
    the chinese word will be=> ¤¤
    base6,utf-8 =>中
    uuencode,utf-8 =>? =EF=BB=BF =E4=B8=AD

    plz help me! thanks!

  • athlon

    and send by gmail

    中æ

  • http://www.mypuppet.net/ Anand

    There seems to be a bug in the code that is causing the “foreach” errors everyone is reporting. If you send an email without a “[category]” bit in the subject, the script does not assign any category at all (instead of use the default category as it should).

    In function get_content, I changed this:

    if ( preg_match(‘/^\[(.+)\] (.*)/’, $subject, $matches) )
    {

    }

    to this:

    if ( preg_match(‘/^\[(.+)\] (.*)/’, $subject, $matches) )
    {

    } else {
    $post_categories[0] = get_settings(‘default_category’);
    }

    and it started working fine. Otherwise, this seems like a great script!

  • http://www.alex101.net Alex

    There are few problems I have.
    1. There is no brackets [ ] in my mobile phone.
    2. In the function get_content there is no
    if(preg_match
    3. I’ve moved to WP 1.5 and can’t get this script work.
    It always says there is no email:
    http://www.alex101.net/wp/wp-mail.php
    4. I’m wondering, should this script run by itself regularly?
    5. Would it be better if subject would have semicolon devider
    between category and subject:
    GENERAL: My subject line

    Please, please, please, fix the bugs and make it work with 1.5

  • Jared

    I got it all installed, I am wondering where you go to configure what email addresses are allowed to post. I sent an email from my phone to the email address and cron is not processing the task. When I manually click on wp-email I get this:

    #!/usr/bin/php -q
    Invalid sender: phone@itsemail.com !
    Not adding email!

    I would like to have it set up so I can send from several different email addresses (work, home and two cells).

  • http://gnbi.com/blog Otis Riggins

    I wound up with loads of image files I had uploaded to my blog while testing. After I deleted the test messages I still had lots of orphaned image files left over in the wp-photos directory.

    I wrote some code to clean up my wp-photos directory and thought it may be of use to others.

    Click Here to display the code and save it to you blog root.

    If the above link fails you can find it on my blog at

    http://gnbi.com/blog/?p=171

  • http://cms.elfden.co.uk/ Rich Pedley

    Sounds like you have done a lot of work with this, I have just posted on the WordPress forum for another possible enhancement/feature that you might want to consider:

    http://wordpress.org/support/topic.php?id=27433

    or not of course :-)

  • http://www.lansmash.com John B. Hewitt

    Rich, thanks for your comments…
    It is feasible, but ultimately painful for the user.

    My wp-mail hack has some limited security, it only allows people to e-mail wordpress if they are a valid user in the wp authors. this is open to abuse by falsely sending e-mails under your own e-mail address, but still some limits.

    I have been working on a GPG/PGP authentication model where unless the message is signed it won’t post in wordpress… but i think the need for this is limited. So far you have to worry about comments in your blog from online poker companies, not e-mail abuse.

  • Mike

    Anand’s fix for the default category doesn’t seem to work fully if your default category for posting by e-mail is not 0 (mine is 4, as set in WP’s web admin screens anyway). The post is still put in category 0 (Uncategorized) but if you go to edit the post, then it appears with the right categories selected on the right hand side of the edit screen… bizarre.

    I also have the same problem as others with posting HTML comments from Thunderbird with embedded images – I get a broken image (with a URL like cid:… @mydomain) and the actual image at the bottom. It works even less well in Outlook Express but I suspect that is because OE sends two copies of a HTML message, both a plain text one and HTML…!

    I’m also getting the problem of senders not being identified when posting. The post goes through, but the sender is not identified on the post.

    Overall a great add-on, if the few bugs could get fixed it would be fantastic!

    Mike

  • http://www.lansmash.com John B. Hewitt

    Ask and you shall receive, wp-mail 0.312 is now ready to download and has these bugs fixed!

  • http://www.struzenberg.com/blog Crumb

    So, I might be a dork.. but I recently installed wordpress 1.5 and decided to go with a moblog. I wanted to use my phone to Doc my day. so this cool tool a try and might have missed a step. I dragged the three files “note: says two in docs” to the blog root. Made the two folders and chmod 777 then went for the blog/wp-mail.php to update the data and got.

    Fatal error: Call to undefined function: checkuserposter() in /home/.saffi/edstruz/struzenberg.com/blog/wp-mail.php on line 248

    doah.. look like I need to be a user.. So I made my phone a user.

    I guess the questions are
    Does it sound like I’m on track?
    Do I need to pass other arguments in the title line or just goup?
    Do I need to include the password someplace?
    am I a dork not finding FAQ’s and posts that r rt in front of me?
    Will my wife ever forgive me for the time I spend playing WOW?
    Thanks for all the work.
    Crumb

  • http://www.ellenogrady.com/blog dave

    I’m getting the same message as Crumb:
    Fatal error: Call to undefined function: checkuserposter() in /home/elleno2/public_html/blog/wp-mail.php on line 248

    I am sending from an address listed in the Authors & Users list. What do I need to fix?

    thanks,
    Dave

  • ddman

    John Blade posted a new version of this plugin here: http://blade.lansmash.com/?p=156

    The fix for the problem you’re having is also listed in the comments of that post…

  • http://www.dipills.com Online Pharmacy

    Interesting article… Haven’t heard about it yet.

  • http://travis-credit-union-dixon.credit-it.info Anonymous

    travis credit union dixon…

    travis credit union dixon news and reviews…

  • bx

    Hello John. Hope you receive this comment. I was unable to download your WP Mail plugin, because all the links to the files lead to your homepage, for example, try http://blade.lansmash.com/wp-filez/wp-mail-0.312.zip – it just opens your homepage. Anyway, I would be very thankful if you sent me the latest version of your WP Mail files to address given with this comment. Thank you in advance!

  • http://www.andyk.de AndyK

    Hi John :-)
    Hope you read this comment as time pass by.

    Can’t access the blog entry WP-Mail 0.312 – Some bug fixes. I’m always getting error 404. :-?
    And in this entry it’s the same for the download of wp-mail-0.311.zip.

    Using FireFox 2.0.0.1

    Could you send me a link to download or send me the latest version?

    greetings from germany

    AndyK

  • http://www.andyk.de AndyK

    Well… the successor called “postie” I found at http://www.economysizegeek.com/wp-mail/

    Andy

  • http://www.dannyonline.net Dannnny

    Same here.. link to the newest article isn’t working and neither is the download link in this article. PLEASE HELP!! Dannnny wants to try this!!