web technology is a way of life
Yesterday, I posted my first post via BlackBerry after dealing with a few issues in WordPress that required a little modification to the wp-mail.php file. Seems that HTML emails don’t get through very well. So here are two basic steps to posting via email with your BlackBerry.
Set up your BlackBerry user account as an Author. From the Dashboard, go to Users and add the email account you use on your Blackberry, your name and a different login and password (you won’t really need these as this account is for email posting) and the Role to Author. Optionally, after you save go back to the new user and set the Display name as your name, so all posts look the same.
Now overwrite your wp-mail.php file with this one.
Here’s the code I changed:
if ($content_type == 'multipart/alternative') {
$content = explode('--'.$boundary, $content);
$content = $content[2];
$content = explode('Content-Transfer-Encoding: quoted-printable', $content);
// BlackBerry Conversion Code
$content = $content[0];
$BODY = strpos($content, '<BODY>');
if ($BODY !== false && $BODY > 0 && $body === false) $content = substr($content, $BODY);
$patterns = array ( '/<FONT FACE\=3D\"Verdana, Helvetica, Arial\"><SPAN STYLE\=3D\'font-size\:12\.0px\'>/',
'/<\/SPAN><\/FONT>/',
'/\=[\n\r]+/',
'/<BODY>[\n\r]+/',
'/<\/BODY>[\n\r]+/',
'/<HTML>[\n\r]+/',
'/<\/HTML>[\n\r]+/',
'/<BR>/');
$replace = array ('', '', '', '', '', '', '', '<br />');
$content = preg_replace($patterns, $replace, $content) . '</p>'; // replace and add trailing P tag
$content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><span><div>');
} else if (stripos($content_transfer_encoding, 'quoted-printable') !== false) {
$content = quoted_printable_decode($content);
}
$content = trim($content);
Try it out, let me know if you have any issues.
The Livescribe Pulse smartpen gets an app store. This little pen is quite amazing, and it just shows that the business model of an app store is already changing the market for every type of electronic device. So when does my…
The Ghostwire (DSiWare) game looks great and reminds me a lot of Fatal Frame.
FloorPlanner is an interesting bit of software built in Flash that allows you design your home in 2D and view in 3D.
The new Stargate Universe [Philosphocal] teaser looks awesome. I stopped watching Atlantis a bit ago because it got boring, I hope this pumps up the energy as BSG did. It has Lou Diamond Philips and Ming-Na in it, that could make…
Here’s a plethora of well designed RSS Feed icons for free!
9 Responses for "Posting to WordPress via BlackBerry"
I have been attempting to set up the post by email features to work with my Blackberry as well. What I really am hoping for would be the ability to post by email AND to upload/post photos and/or videos. So I have actually been trying to work with the Postmaster plugin (http://wordpress.org/extend/plugins/postmaster/) which allows for file uploads.
With the postmaster plugin installed, I can email posts to my site and they are uploaded successfully BUT they appear in Base64 code, so it’s a jumbled mess of letters and words, and I have to fix it later.
I made the changes you mentioned (after installing postmaster) but that only created an error within wordpress when it “checks its email account” (Parse error: syntax error, unexpected ‘}’ in ***mysite***/wp-mail.php on line 162).
Do you have any thoughts on how to fix this, and how to make it possible to email from the blackberry (without it appearing in Base64 code) and to upload files via email?
Thanks!
Melinda,
You should be able to fix the base64 issue with base64_decode(). I needed to add this code to grab base64 encoding:
I updated my wp-mail.php download with this code along with my twitter updater code I blogged about recently.
Without knowing exactly what you have on lines 161-162 I can only assume that you have a mismatched bracket pair and are missing the ending bracket ‘}’. If you want post the code on those lines or send me the wp-mail.php file via the “Contact Joel” link above.
Thank you, Joel- I really appreciate your help! I’m a coding novice so I tend to be quite dangerous with the code. :)
I’ve been trying to sort out my wp-mail file so that I can post from my blackberry as well as upload files. I created a file on my website (http://melindamusil.com/wp-mail/) with my “collection” of wp-mail.php files. They’re all saved as .txts so that you can see them and make recommendations as you see fit.
wp-mailorig is the “original” wp-mail file that you get when you download wordpress.
wp-mailpostmaster is the slightly adjusted file that came with the Postmaster plugin. PM allows for uploading of files (pics, vid) via email. However it does not decode base64 in emails sent through my blackberry.
Trials 1, 2, and 3 are various wp-mail files that I have created with the goal of a file that can upload files as well as interpret text from my blackberry. None of them were successful, but perhaps they will give you some ideas.
If you have any questions, ideas, or solutions, please email me at melinda@melindamusil.com!
speaking as a coding novice…
Would it help to add a base64_decode () function to the wp-mail.php file?
Most likely it should =)
You’ll need to find the base64 encoded part, generally marked by “Content-Transfer-Encoding: base64″ and then you can decode that chunk.
Joel- have you had a chance to look at this?
I’m highly frustrated by this issue. Right now I have a so-so solution but it’s not where I want it to be yet. You can see the wp-mail file I’m using at http://melindamusil.com/wp-mail/wp-mailpostmaster.txt. With that file, I can successfully email and post photos and small amounts of text (one or two sentences, basically a caption for the photo). I’m glad to have that much, but I would really like to be able to successfully email and post larger amounts of text. If you get a chance, please please please let me know your ideas!
Thanks!
This is a bit tricky, since knowing what your email provider is sending a long to your blog is the issue. You should modify your wp-mail.php file to print out the complete email. Then access the wp-mail file directly (not through the iframe) so you can see what is printed. Then you;’ll be able to see where the encoding takes place. Try it with both large and small emails to see what is different.
Just saying hi to you!
I like this blog, the more I read the more I like it.