Monday, January 31, 2005

SMTP email attachments from nokia 6600 using t-zones



I wanted to post images to flickr fom my phone and realized that the email app that comes with nokia 6600 (t-mobile) doesnt let you send attachments more than 1K! But as always there are workarounds in the net including an firmware upgrade(!) and using one of those third party email apps possibly with an external SMTP server - and people who tried these have had mixed results. To me, none of the options sounded very appealing so I decided to write my own midlet to send attachments. Moreover having my own midlet meant I can take pictures and send the same in one shot - was defenitely worth trying. So here's is what I did.

1. Use MMAPI to take pictures - basically followed the MMAPI sample program that comes with the WTK. I used VideoControl.USE_DIRECT_VIDEO display mode and png encoding for the snap shot. Here's the caveat: with MMAPI, you'll never get the same resolution as the native camera app. But that was OK, I was just gonna use it for moblogging.

2. Open a simple socket connection to myemail.t-mobile.com, port 25 and Send the picture that you captured using basic SMTP commands. T-mobile uses secure SMTP - so you need to pass in your creditials - no ssl though(btw 6600 do support ssl). Here goes the commands
a) EHLO
b) AUTH PLAIN {Base64 encoding of "\000" + user + "\000" + password}
c) MAIL FROM: < {your email addr} >
d) RCPT TO: < {flickr email addr} >
e) DATA
f) MIME-Version: 1.0
g) From: < {your email addr} >
h) To: < {flickr email addr}>
i) Subject: {some subject line}
j) Content-Type: multipart/mixed; boundary=" {some unique string} "
k) \r\n-- {my unique string}
l) Content-Type:image/png; name=image1.png");
m) Content-Disposition: attachment;filename="image1.png"
n) Content-transfer-encoding: base64
o) \r\n\r\n
p) {Base64 encoding of the image} - just google MIMEBase64 in case you need an impl.
q) \r\n-- {my unique string}
r) \r\n\r\n-- {my unique string} --\r\n
s) .
t) QUIT

3) Add some screens for configuration - email, server, port etc (throw in some RMS code also if you have the time), an Image thumbnail so you can select and preview before you post.

Thats it.. Done! Your very own moblog software is up n running in no time!

1 comment:

Anonymous said...

Why did you use SMTP instead of HTTP?