cURL / Mailing Lists / curl-users / Single Mail

curl-users

Using curl to get Yahoo mail

From: Kerry Nice <politemadness_at_yahoo.com>
Date: Fri, 22 Mar 2002 15:47:24 -0700

Has anybody here figured out how to use curl to get email from yahoo
accounts, something like gotmail does? I've tried a few times but didn't
get very far with this. I get confused by the cookies and the redirects and
other things. It seems that now they want to charge for pop access, this
seems a little more desirable to figure this out.

I've looked for something already written, but I haven't found anything yet.

Here is what I have so far, any idea how to make this all work?

#get the login page
curl -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" -b
cookies -s -L --url "http://mail.yahoo.com" > yahoo0.html

#find login url
url=`grep -i "post action" yahoo0.html | sed -e 's/^.*action="//' -e
's/".*//'`
#result should be
#https://login.yahoo.com/config/login?9dmb3dv11h8j3

UVAL=`grep -i "\"\.u\"" yahoo0.html | sed -e 's/^.*value="//' -e 's/".*//'`
CHALLENGE=`grep -i "\"\.challenge\"" yahoo0.html | sed -e
's/^.*value="//' -e 's/".*//'`
USER='XXXX'
PASSWD='XXXX'
curl -v -L
"login.yahoo.com/config/login?.tries=&.src=ym&.last=&promo=&.intl=us&.bypass
=&.partner=&.u=${UVAL}&.v=0&.challenge=${CHALLENGE}&.emailCode=&hasMsgr=1&.c
hkP=Y&.done=&login=${USER}&passwd=${PASSWD}&.persistent=&.save=1&.hash=0&.js
=0&.md5=0"

Here is the general sequence it should follow:
#initial login page
mail.yahoo.com/

#logged in, opening page
login.yahoo.com/config/login?.tries=&.src=ym&.last=&promo=&.intl=us&.bypass=
&.partner=&.u=5kg8k3cu9nbde&.v=0&.challenge=jk378y4LMRhbeez32tEmWIi_cyNk&.em
ailCode=&hasMsgr=1&.chkP=Y&.done=&login=XXXX&passwd=XXXXX&.persistent=&.save
=1&.hash=1&.js=1&.md5=1
f148.mail.yahoo.com/ym/login?.rand=ecqsa2p5hkkmb
us.f148.mail.yahoo.com/ym/login?.rand=ecqsa2p5hkkmb
us.f148.mail.yahoo.com/ym/Navbar?YY=47595
us.f148.mail.yahoo.com/ym/login?.rand=ecqsa2p5hkkmb&LgnDn=1

#check mail link, to inbox
us.f148.mail.yahoo.com/ym/ShowFolder?rb=Inbox&YY=41323&YN=1

#get a message
us.f148.mail.yahoo.com/ym/ShowLetter?MsgId=843_12829_638_983_3262_0_18502&YY
=92536&inc=200&order=down&sort=date&pos=0&view=&head=&box=Inbox

#get full headers
us.f148.mail.yahoo.com/ym/ShowLetter?box=Inbox&MsgId=843_12829_638_983_3262_
0_18502&Search=&Nhead=f&YY=72216&order=down&sort=date&pos=0

#get printable view, I assume this can be combined with the last step
us.f148.mail.yahoo.com/ym/ShowLetter?box=Inbox&MsgId=843_12829_638_983_3262_
0_18502&Search=&PRINT=1&YY=20021&order=down&sort=date&pos=0&head=f

This view has a bunch of html in it, but it doesn't look very hard to strip
that out.

I haven't figured out delete yet. One version I looked at uses javascript
and looking at it in lynx it uses a form. But if I can log in for now, I
would be more than happy. The rest of it should be easy once I have a
framework on how to do this.
Received on 2002-03-23