0

I am a student at an university that maintains an internal mail server(zimbra). All the important mails are delivered to this account. But the fact is that no one bothers to check their mail. I am writing this bash script that notifies the user when a new mail is delivered to the inbox.I have figured out a way to find the number of unread mails from the page that is returned after the login(post method)[the title has the unread mail count,so it is just a few "greps" and "seds" away from the number].....

I guess zimbra suite has an api,but I have just started to learn python so I have no other choice but to rely on curl. The form is as follows(i've filtered out the input tags)

<input type="hidden" name="loginOp" value="login"/>
<input id="username" class="zLoginField" name="username" type="text" value="" />
<input id="password" class="zLoginField" name="password" type="password" value=""/>
<td><input id="remember" value="1" type="checkbox" name="zrememberme" /></td>
<td><input type="submit" class="zLoginButton" value="Log In"/></td>

We need to use a proxy server to connect to the internet. And the https connection is not secure,,so the -k I am not sure about the last line but I managed to form this

curl -A 'Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0' -c cookies.txt -k -x 10.1.1.26:8080 -d "loginOp=login&username=xxxxx&password=xxxxx&zrememberme=1&Log+In" https://warrior.bits-goa.ac.in/zimbra/?zinitmode=http > 2.html

The "Log In" button doesn't have a name. That's weird! (ok! I accept I have never come across a similar form) Or is it the cookie? The curl manual recommends the netscape cookie.

The output file is the same as the login page but with an added "Your browser doesn't support cookies" line. What do I do??

Also there is this wonderful addon called tamperdata for firefox. I am not able to install it cause for some reason the net admin has blocked the link to download the addon.[ I don't trust the proxy sites ;) ].Can someone post the post data with a random login on this site. http://warrior.bits-goa.ac.in

Thanks! And sorry for the elaborate question.I want to learn this once and for all :)

3
  • 1
    Well, this is not an answer but a batchmate of mine made a similar script for our institute. It uses the same zimbra. Check it out. sprunge.us/eNLH . Modify it to suit your needs.
    – shadyabhi
    Commented Feb 9, 2012 at 13:17
  • Does your university provide email via IMAP/IMAPS? Commented Feb 9, 2012 at 13:38
  • @AbhijeetRastogi:the code fails...the reason urllib/urllib2: HTTPS over (Squid) Proxy fails. the same bug that has been "tormenting" empathy IM since ages. :( thanks anyways. ArjunShankar:No sir..all the ports other than 80 and 443 are blocked.It is too restrictive here. Commented Feb 9, 2012 at 13:59

1 Answer 1

1

curl is definitely (one of) the right tool to use: you just need a --cookie (and maybe a glass of milk) initialize the cookie with -b and use it with -c. Here is an example where I used it for dropbox:

http://murga-linux.com/puppy/viewtopic.php?p=597711#597711

and where I learned the curl commands for it:

http://curl.haxx.se/docs/httpscripting.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.