<D <M
Y> M> D>

2005-03-17T22:51:10 Automatic display of incoming picture share:

Update: I have a better sprintpcs picture mail reader now which can post to blogs and understand both the Treo 650 and Treo 750 picture mails. Leave comments there or email me if you want more posts about how that's done.

I put this in procmail::

:0 c

* ^Subject: A Picture Share!

| $MAILDIR/pictureshare

And this is in Mail/pictureshare:

#!/usr/local/bin/python2.3

# if mail contains a link like this, launch mozilla on dash. part of
# the url will end up in a shell command, so i limit the url tightly.
# if there is not a good enough match, this program silently exits.

# &lt;a style="color: #FF0000;" href="http://pictures.sprintpcs.com/share.jsp?invite=gEZm4LPf8UzcFaCLk8Zx&amp;amp;shareName=Photo">View&lt;/a>

import sys,re,os
msg = sys.stdin.read()
m = re.search(r"""href="http://pictures\.sprintpcs\.com/share\.jsp\?invite=([a-zA-Z0-9]+)&amp;amp;shareName=Photo">View""",msg)
if m:
remote_cmd = "DISPLAY=:0.0 scripts/newmozilla http://pictures.sprintpcs.com/share.jsp\?invite=%s\&amp;amp;shareName=Photo" % m.group(1)
print "launching mozilla on dash for picture share email"
os.system('source ~/.ssh-agent-dot; ssh dash "%s"' % remote_cmd)

And this is scripts/newmozilla on dash:

#!/bin/zsh

URL=$1
if [[ $URL = "" ]]; then
URL=http://google.com
fi
/usr/local/mozilla/mozilla -remote "openurl($URL,new-window)"

For testing, I run received mh mails through the program:

dot(pts/0):~% cat Mail/inbox/127 | Mail/pictureshare
launching mozilla on dash for picture share email


[Main]

Unless otherwise noted, all content licensed by Drew Perttula
under a Creative Commons License.