As I have promised, I created a little ruby script which can easily be translated into Perl, PHP, or whatever language of your choosing. You are required to somehow pipe the e-mail to your script which there are various methods to do so, I will be explaining it using Dreamhost because that happens to be my current web host as of this writing.

Let’s get started

The Process:
What we are doing here is we are forwarding SMS messages (theres an option in your google voice settings) to your GMAIL account. On your GMAIL account you are going to then forward the message using a filter to a domain name e-mail address, which will then be piped to the script. The script is going to parse the raw email (convert raw data into something readable) and finally send it to your iPhone using the Prowl API (you will need to have the Prowl App installed on your iPhone).

No that we got that out of the way login to your Google Voice account and click on the Settings link. Then select the Voicemail and SMS tab. Under the Voicemail Notifications section check the box that says “Email the message to:“.

Logon to your GMAIL account and click on the Settings link select the Filters Tab and at the very bottom click the Create a new filter link. In the From Field enter the following:

*@txt.voice.google.com

Click on Next Step and Check the following boxes:
Skip the Inbox (Archive it)
Forward it to: THE DOMAIN EMAIL ADDRESS YOU WILL BE CREATING SOON
Delete it

You have successfully completed the easy part of this!

As I have mentioned before this guide will walk you through using Dreamhost as your hosting services. It can easily be done by other means with your host just send them an e-mail or try to follow the general idea of this guide Incoming Mail and PHP.

Login to your Dreamhost Panel and go into the Mail -> Manage E-Mail section. You are going to create an e-mail address using the email address you added to the GMAIL filter that is going to only forward mails to your server mail. What I mean by that is say I used in my GMAIL filter SMS@YOURDOMAIN.COM then create that same address in your Email panel on Dreamhost but select the option to only forward incoming mails to this address to your local server email. Your local server email address on Dreamhost is your username@server.com for example the server im on is jebediah.dreamhost.com then I’m going to use DREAMHOST-USERNAME@jebediah.dreamhost.com. You can easily get the server address by logging in using SSH it will be one of the lines that appears when you login.

Next thing we will need to do is create a file named .forward.postfix with the following contents and put it in your root directory:

Also create another file named .procmailrc with the following contents and put it in your root directory as well:

The only thing you need to know here is that the last three lines matches the forwarding e-mail address we created on your host and tells it to forward that incoming e-mail to the ruby script. The reason why we are matching for “X-Forwarded-To” is because we are forwarding from our GMAIL and therefore the e-mail address we created on our webhost wont appear in the “To” field of the raw e-mail.

The Ruby script is very plain and simple create a file named mail.rb and put it the root folder or wherever you wish to just as long as you are properly specifying its full path in the .procmailrc file, with the following contents:

The script is pretty straight forward we are using the TMAIL gem and the Prowly gem. The Tmail gem basically takes the STDIN input (the raw email) and parses it to something more usable to send to the Prowl API.

Of course this is a one user scenario, if you wish to support multiple users and higher volumes you may want to look into using other means. I originally created a similar version of this script in PHP which just grabs the raw data and performs a post request to another script in order to keep things to a minimum on the piped script.

Once you have the raw e-mail parsed you can basically do anything you want. You can match the mail.to e-mail address to a local database and extract the Prowl API from there to support multiple users. Or even go a step further and send the message to your GTALK by creating a simple XMPP bot. This script is very much open source, do as you wish with it. I’m pretty new at writing things in ruby so if you have yet a more efficient way of doing this please let me know.

Useful resources:
http://www.evolt.org/incoming_mail_and_php
http://tmail.rubyforge.org/
http://prowl.weks.net/api.php
http://github.com/rafmagana/prowly

If you have not yet heard of google voice its basically a service that provides you a phone number that you can use to make phone calls, and send and receive text messages through google. In any case the best way to find out about the service is to simply watch the videos posted on the website at http://www.google.com/googlevoice/about.html.

Google Voice is a very convenient service because it can save you money on your cell phone bill by no longer needing to pay the extra $15 for unlimited text messages all you need is access to the web. This service is easily available on any phone that uses the Android OS. Unfortunately Apple did not approve the Google Voice app on the iPhone appstore and therefore there is no easy way to receive push notifications to your iPhone when you have received a text message or voice mail on your google voice number. The closest thing you have is the ability to receive e-mails that are forwarded to your phone (if you have your e-mail set up on your phone).

Luckily you still have some options if you are an iPhone owner. You do need to jump through a bit of hurdles if you wish to get this done though.

Things you will need:

  1. An iPhone.. Duh!
  2. Prowl (iPhone App)
  3. Either an account at: http://googlevoice.ub3rk1tten.com/voicegrowl/ or with https://www.gvmax.com/

I have used the Voice Growl service in the past and works quiet well, with the exception that at times the service does go down for a few minutes. I have not tested or used GVMax but it does sound promising and the software is now open source as well which may be something you Java nerds may like to take a look at.

Sadly enough these services provide you with a means to receive Push notifications to your iPhone when you receive a message but still does not provide you with an easy means to reply back. You can simply use googles renovated google voice mobile site which works well but depending on how fast your connection may be can slow you down. Or if you have a jailbroken iphone you can always give the app found in Cydia.

If you are one handy developer there are also many libraries written in various languages that you can use to your advantage for receiving and replying to messages. Prowl has various 3rd party libraries you can use to send notifications to your iPhone. I have found the php library found at github to work well for all my needs http://github.com/Fenric/ProwlPHP. Aside from that there are also various third party libraries for Google Voice (aka unofficial google voice api) in many languages all you need to do is perform a google search, I currently use the PHP library found at github http://github.com/aaronpk/Google-Voice-PHP-API. If you are a developer with a little creativity and a bit of time you can come up with a good solution for your iPhone Google Voice needs.

I will soon be posting my own code as well as I currently use Google Voice -> My Dreamhost Procmail -> Prowl & Gtalk to receive messages and currently working on an XMPP format to send messages back.

LA Ruby Meetup

Posted October 26th, 2009. Filed under Computers, Internet, Tech

A few weeks ago I attended my first LA Ruby meet up. Basically it’s a group of Ruby enthusiasts getting together and talking about Ruby and Ruby on Rails. I was rather surprised the community was more of an older mature crowd than. I would have expect various to be young web entrepreneurs or something of that liking. There was a speaker at the meetup from Heroku showing off their product and how awesome their dynamic cloud services work. It’s basically a cloud within a cloud which makes for interesting ultra dynamic services. Along with Heroku we also had another guest speaker who spoke of marketing and pitching your web product to the masses. It’s been a while since I blog and thought id share my wonderful experience with the LA Ruby group earlier this month.

Just Learning

Posted April 21st, 2009. Filed under Computers, Internet, Tech

Ever since I came across the Youtube Edu site I’ve been watching a whole lot of programming videos and have picked up a whole bunch of concepts that I would have never learned on my own. Personally I see this as a very good resource to those who really want to learn the concepts of software engineering as well to those seasoned programmers that just need to refresh and get a quick reference to some concept of some kind.

Beginning Programming in Java :
http://www.youtube.com/view_play_list?p=84A56BC7F4A1F852
YouTube Preview Image

Server Pic 2

The Home Server Setup

Parts used:

Installing the Ubuntu Desktop Operating system is pretty plain and simple. All I basically did was install the Ubuntu distro onto my flash drive (I didn’t install a disc drive on the server) and booted the server computer with my flash drive and followed the installation process from there. I decided on using the Ubuntu Desktop version primarily because I wanted to have the ability to use the computer for more purposes than one, for example as a Boxee TV set top, or just as another internet terminal in the household.

Once after I finished installing the operating system I went ahead and installed all the necessary updates which in a sense almost took just as long as the actual operating system installation itself, but no problem that was used as good quality time to serve myself a nice refreshment (beer) and sit back and relax a bit.

Note: Once after installing all the Ubuntu updates and restarted the system I noticed that the NIC card was no longer connecting to the Internet. As I searched through the Ubuntu forums I found out that one of the kernel updates has a little issue with the Intel D945GCLF motherboard. After couple of minutes searching around I came across a post with recompiled version of the update with the issue patched.

The fun part begins

Installing Samba was a walk in the park, all I did was created a folder named TimeMachine (I’ll explain later), and right clicked it and selected sharing options. It prompted me that I needed to install Samba in order to share that folder , and did it automatically after going through the menus. Once having the folder I wanted to share the folder I selected I went on to setup Avahi to broadcast that the server has Samba up and running to the rest of the computers in the network:

Opening Terminal on the Ubuntu Machine and running the following command:

Sudo gedit /etc/avahi/services/samba.service

Copy and paste this into the text editor:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_smb._tcp</type>
<port>139</port>
</service>
</service-group>

Save and Close the file editor, and restart the Avahi service by doing the following:

Sudo /etc/init.d/avahi-daemon restart

Now that my MacBook was able to see the new server setting up TimeMachine to backup to the server was a little trickier. I had to follow a guide that explains how to do this same process but with Netatalk so I had to skip a couple of steps. Basically you have to set up TimeMachine so that it can use network devices for back ups. This is done by going on Terminal on the Mac and punching in a mini code:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

once running this command you should be able to select a network share for backing up data.

The next step was a little trickier.

Time Machine didn’t work right away, it gave me an error, telling me it was unable to create disk image and what not. So what I ended up doing was going under the Utilities folder in the applications folder and running Console, on the left navigation menu I selected All Messages and re-ran TimeMachine’s BackUp Now option and waited while it did its thing. On the Console application you’ll notice after a couple of seconds or minutes a message with something along the lines of:

Creating disk image /Volumes/TimeMachine/computername_0014e3856bd0.sparsebundle

Of course with computername being the name you gave your mac during initial setup. Open up the DiskUtility app and from the toolbar Create a New Blank Disk Image with the name that showed up in the console:

computername_0014e3856bd0.sparsebundle

Unfortunately I didn’t really added a Volume name to it so I left its default name but for the Volume Size I selected a small size.

Volume Format: Mac OS Extended (Journaled)
Encryption: none
Partitions: Single partition – Apple Partition Map
Image Format: sparse bundle disk image

Copied over the image to the shared folder on the server, and jumped on Terminal with my Mac to bloat up that tiny image to something usable, lets say around 500 gigabytes. Navigated to the following:

cd /Volumes/Name of Shared Folder

Remember I had already mounted the share folder on my MacBook simply by going under the file manager and on the left hand side clicking on the server share and connecting as the user I created on the server. Once in the Volumes folder and inside the mounted drive can do a quick ls command to make sure that the sparsebundle image is there. There I ran the command to resize the image file which was:

hdiutil resize -size 500g filename.sparsebundle

Time to give TimeMachine another run.

Believe me that you’ll be glad to have resized the image file after  it was transferred onto the server, otherwise you’d have to sit and wait for an empty 500gig image to be transferred from one computer to another.

TimeMachine worked perfectly after this, the only thing is that it did take some time doing the initial backup because it was nearly 150gigs of data that was transferred.

Links and Resources: