Create an iPhone Note from your Mac and Push it to GMail

iPhone Notes

A Happy New Year to everyone! My Xmas/NYE were spent feeling pretty ill, but some groovy pills from the doctor sorted all that out relatively quickly. Apart from that, much fun was had and even more tasty food was had. Happy days!

Now that’s out of the way, on with the geekery.

So, I use the iPhone Notes app to keep track of things that I need to do. Often, if I have a busy day ahead of me, I’ll want to create a to-do list. So far so normal… Doing this on the iPhone itself ┬ácan be a bit of a pain, especially if there’s a long list or a big chunk of text I want to get down. Ideally, I’d like to create it on my laptop and push it to the phone. Sadly, there’s no built in way of doing this. Luckily, since my notes get synced to my GMail account, I decided there might be a way of simply sending myself an email and it ending up in the right place. This isn’t the holy grail of being to edit the notes afterwards, without needing to do it through the iPhone, but it’s half way there and simple edits can be done without too much pain on the phone itself.

So off I went on my little exploratory mission. All the notes get pushed and synced by the Notes application on the iPhone to GMail and labeled “Notes” (they are also marked as read, which will be dealt with later). I looked inside a test note I created through GMails “view original” option to get a good look at the headers. Here’s what came out:

Subject: Test note
From: Shiv Kaushal
X-Universally-Unique-Identifier: 85B8506D-9634-459B-971E-39C6F48869EE
Content-Type: text/html;
Message-Id: <>
Date: Mon, 10 Jan 2011 23:40:15 +0000
X-Mail-Created-Date: Mon, 10 Jan 2011 23:40:15 +0000
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (iPhone Mail 8B117)

Test note
Testing 1, 2, 3

The parts that make the iPhone app pick up the messages as notes (i.e. things that aren’t there in pretty much every other message in my inbox) are X-Universally-Unique-Identifier and X-Uniform-Type-Identifier: So as long as I can create a message that has these features, all should work as I want.

Once again, I have turned to the power of bash scripting to save the day. The following script makes use of a great little GMail feature, that many people don’t know about or use, in order to let me get things going correctly. You can both punctuate your gmail username with full stops anywhere you like AND put “+blah” after the username (replacing blah with whatever you want). So, instead of, I could use and it would get through to the same GMail account. Without further ado, here’s the script:


if [ -f "$1" ]
SUBJ=`head -n 1 $1`
echo "From:" > $FILE
echo "To:" >> $FILE
echo "Subject: $SUBJ" >> $FILE
echo "X-Uniform-Type-Identifier:" >> $FILE
echo "X-Universally-Unique-Identifier: $id" >> $FILE
echo "" >> $FILE
cat $1 >> $FILE
echo "Sending new note...."
sendmail "" < $FILE
echo Done.
echo ""

rm $FILE


echo "File to send not found!" 


Save that (changing “someuser”, obviously) somewhere in your path and be sure to chmod +x it – I saved it as iphone-txt-to-note. In order for the above script to work, you need to have specified an SMTP server, which is pretty simple to do on OS X if you follow this guide: – I didn’t need any of the SSL options so only needed to follow the first part of the first step. After that, you simply run the script and pass it an argument which is the path to a plain text file that you want to become your new note – iphone-txt-to-note /Users/shiv/my-new-note.txt, for example. The script then extracts the first line to set it as the email subject, constructs the email with the correct headers (including a randomly generated UUID), inserts the full text of your file and mails it to your GMail account. Nearly there!

GMail Filter for iPhone Notes

The final piece of the puzzle is to force GMail to put the email in the right place. The filtering in GMail doesn’t appear to let you filter based on the contents of email headers, which is why I opted to use the “+notemeup” addition to the email address being sent to. This allows us to tell GMail to select all mail sent to “” (you can change the tag to whatever you like, so long as it matches in the Bash script and your GMail filter), apply the “Notes” label, mark it as read and archive it so it doesn’t appear in the inbox, as shown in the image above (click to embiggen).

Now every time I use the Bash script, I can almost immediately open up the Notes app on my iPhone and see the newly created note.

Mission accomplished; Yay!

Leave a Reply

Your email address will not be published. Required fields are marked *