MailTwitterPHP
MailTwitterPHP is an email to Twitter gateway script. MailTwitterPHP will make an attempt to connect to a specified IMAP inbox, cycle through all email and attempt to post the body of each email as a new Twitter to a specified Twitter account. POP3 is currently unsupported, although support will be added in a future release. MailTwitterPHP is designed to run as a shell script rather than as a Wordpress plug-in or general purpose PHP code on a web page.
I wrote MailTwitterPHP because although my mobile phone does have a web browser, it will not login to Twitter and allow me to update my status. Additionally, Japan does not have SMS capable mobile phones. Those of us in Japan are effectively locked out of updating Twitter when mobile. This lead to the inspiration for the script; I desired to update my Twitter status when mobile and set out to make that possible. Twitter’s exposed API endpoints made MailTwitterPHP possible.
Twitter, for those who have no idea what it is, is a service that allows one to update their “status” quite easily and without thought. If you are, say, watching a movie then you can tell all your friends that you are doing so quite easily. What I really like about Twitter is that it allows you to keep the fluff off of your blog while still keeping your friends apprised of your status. It is almost like guilt-free blogging for those “useless” posts that would otherwise be left out in the abyss. Try it out and see for yourself. Then add me as a friend.
MailTwitterPHP is the first PHP script that I have ever released in this capacity. Although I have created a web site here and there, I have never had my code exposed to the world in this manner. It feels somewhat awkward yet simultaneously liberating. If anyone notices anything awry with the script, or something that looks out of place, then please let me know. I am extremely open to ensuring that the script is not riddled with any issues.
As already mentioned, MailTwitterPHP is designed to run as a shell script. The ideal method would be to create a cron job that calls MailTwitterPHP every 5 minutes, or whatever timeframe deemed necessary, so that it can poll the specified IMAP inbox and update Twitter with any updates awaiting on the server.
POP3 is currently unsupported but will be added in the next release. Since I have no use for POP3 I opted to release the script solely with IMAP support at the moment. The addition of POP3 support is actually fairly minimal. Even so, I would much rather gauge feedback on the script before moving along with development of MailTwitterPHP.
It is recommended that a mailbox be created for the sole purpose of MailTwitterPHP. The script is designed to delete email without prejudice and will, therefore, remove any and all email awaiting on the specified server, even if you “saved” it. An additional small security feature in MailTwitterPHP only allows email with the correct subject line to be posted to Twitter.
PHP must have IMAP support compiled in otherwise MailTwitterPHP will not function, as it relies on the IMAP library in order to function. If you are unable to use MailTwitterPHP due to the lack of IMAP support then please contact your ISP, or compile PHP with IMAP support on your own
Any and all thoughts and ideas are welcome and will be thoroughly considered before possible inclusion in future releases.
Download MailTwitterPHP from its project page.
Update 1: It appears as if Twitter’s API endpoint for posting has been disabled at the moment. This is probably due to an exploit that was found earlier. I am not sure when the API will once again be available, but hope that it is relatively soon.
Update 2: MailTwitterPHP has been updated to ensure that it is using a POST, as defined in the Twitter API, and is once again functional. All rejoice!
After checking this out on your site, I kind of like the idea of having useless stuff out of sight…nifty thing.
Hallo!
We did indeed close up the hole that was being exploited, but you can still make updates via the API - just use HTTP POST instead of HTTP GET, and everything should work fine.
Mom: It is a fun thing to “play” with.
Blaine: Thanks. I totally screwed the pooch on that and did not use POST in the beginning. Changed that and the script works like a charm. Many thanks again!
Scott: Yes, you seem to have “fun” with it…lol…judging from some of your comments…
Check out mail2twitter.com, it’s a very easy way to tweet from everywhere for free using your mobile email!
How long are we looking at for pop3 support. I do like the sound of this script though. Very nice!
Hello Jark! I just wanted to thank you for this awesome software - i live in Tokyo too and twitter and blog & make podcasts about living in Japan & technology - so you are like a brother in arms! (i found you while randomly floating on Twittervision 3D). Plus, I’m a huge fan of DEVIANTART! That’s amazing! Anyway, please add me as a friend on twitter - with so many similar interests, I’d love 2 get your opinions on some of the things that make up life in Tokyo