[imp] custom login

Mark Merchant mmerchant at dispatch.com
Fri Jan 31 15:24:32 PST 2003


>Here is the code for the login part - other stuff like handling the
>variables and the form itself are in other pages which can be provided
>reasonably easy...

derek,

thanks for the code. looks very much like what i had. the key seems
to be the referer.

in case anyone is interested, here is what an automated imp logon
cgi might look like if written in shell script. no warranty is made, use
at your own risk. careful, lines may be wrapped.

-MM-


#! /bin/bash

# ----------
# example shell script for an automated imp login
# ----------
# Uses: curl
# ----
# Auth: MM
# Date: 1-8-2003
# Rev : 0.1
# ----------

# CONST -- Set these vars with your site or user info
         UA="Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" # user agent
         REF="http://xxx.xxx.xxx.xxx"                                     # 
referer name or IP
         CO1="/tmp/cookies1.tmp"                                          # 
temp file
         UD="xxx" 
# imap user id
         PAS="xxx" 
# imap password
         MSV="imap" 
# server name
         HSV="http://xxx.xxx.xxx.xxx"                                     # 
horde server name or IP

#
# create a cookie file
#
         touch "$CO1"

#
# use curl to get the horde session id from the login page
#
         curl -s -L -A "$UA" -D "$CO1" "$HSV/horde/imp/login.php" 
1>/dev/null 2>&1

#
# use curl to post the form and send the session id
#
         curl -s -i -A "$UA" -e "$REF" -b "$CO1" -d 
"actionID=105&url=/horde/imp/mailbox.php&mailbox=INBOX&imapuser=$UD&pass=$PAS&server=$MSV&folders=&new_lang=en-US" 
"$HSV/horde/imp/redirect.php" -o /dev/null

#
# play the doc headers from the login page
# back to the users browser.
#
         cat "$CO1"|egrep -v ^HTTP|sed -n '/[:alpha:]/p'

#
# remove the cookie file
#
         if [ -e "$CO1" ]; then rm -f "$CO1"; fi

#
# redirect the users browser to the mailbox page
#
         echo "Location: $HSV/horde/imp/mailbox.php"; echo


More information about the imp mailing list