# HotMail # # @Requires: 1.1.1 # @Version: 1.1.11 # visible version number corrected # @Version: 1.1.10 # fixed after hotmail change (thanks to Adam Peaslee) # @Version: 1.1.9 # german texts (with MrPostman 1.2.2+) # @Version: 1.1.8 # added additional mail header for folder name (requires MrPostman 1.2) # @Version: 1.1.7 # added support for Hotmail Plus accounts thanks to Reuven Wachtfogel (RW) # @Version: 1.1.6 # fixed the changed login (solution by hkbobo) - non-changed accounts should still work # @Version: 1.1.5 # uses fixed getformfields of MrPostman 1.1.1 # @Version: 1.1.4 # fixed deleting of mail # @Version: 1.1.3 # included patch of Kurt Godwin # fixed login problem, incl. patch for getformfield # @Version: 1.1.2 # message links now more specific to avoid getting compose link # @Version: 1.1.1 # corrected folder link construction (and silly bug) # @Version: 1.0 sub getInfo local(info) info.name = "hotmail" info.authors[0] = "Chris Humphreys " info.authors[1] = "Martin Vlcek " info.version = "1.1.11" info.updateService = "" info.documentationLink = "/en/hotmail/index.html" info.options["folders"].order = 1 info.options["folders"].value = "F000000001, F000000005" info.options["folders"].label = "Folders" info.options["folders"].description = "Folders from which messages are downloaded, e.g. for inbox & junk: F000000001, F000000005" info.options["onlyUnread"].order = 2 info.options["onlyUnread"].value = true info.options["onlyUnread"].label = "Unread Only" info.options["onlyUnread"].description = "Collect only Unread mail" info.options["markRead"].order = 3 info.options["markRead"].value = true info.options["markRead"].label = "Mark read" info.options["markRead"].description = "Flag the collected messages as read" #--- german texts info.options["folders"].de.label = "Ordner" info.options["folders"].de.description = "Webmail Ordner, aus denen Nachrichten heruntergeladen werden sollen, z.B. für Inbox & Junk: F000000001, F000000005" info.options["onlyUnread"].de.label = "Nur ungelesene Nachrichten" info.options["onlyUnread"].de.description = "Nur ungelesene Nachrichten herunterladen" info.options["markRead"].de.label = "Als gelesen markieren" info.options["markRead"].de.description = "Alle heruntergeladenen Nachrichten als gelesen markieren" return info end sub getExtensions return list("@charter.com","@compaq.net","@hotmail.co.jp","@hotmail.co.uk","@hotmail.com","@hotmail.de","@hotmail.fr","@hotmail.it","@msn.com","@passport.com","@webtv.net") end # Here you can see that for a login to Microsoft you have to handle: # - redirects both of gets and posts # - redirects to other hosts # - HTML meta tags to redirect to another page # - Forms automatically submitted by Javascript # - Invalid cookies sub login(username,password) local(domain,domain1,action,form,params,status,page,found,url,um) setcookiemode("RFC2109") setuseragent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)") #--- no message sizes available, date is in correct format #--- let's log in - go to start page: found,login,domain = match(username,"(.*)@(.*)") #domain1 = replace(domain,"[\.\-]","_") status,page,headers = get("http://www.hotmail.com") #--- on the resulting page is a form, which is normally automatically submitted by javascript found,action,form = match(page,"]*\saction=\"([^\"]*)\"[^>]*>(.*?)") params = getformfields(form) status,page = post(action,params) #--- now we are on the actual login page: #--- (1.1.3) now there is only one form, action link is determined by JS, see below found,action,form = match(page,"]*\sname=\"f1\"[^>]*\saction=\"([^\"]*)\"[^>]*>(.*?)") returnif(!found,false) params = getformfields(form) # -- now, get the g_QS and g_DO values and form the "new" action # -- (see OnSigninSubmit() javascript function on the signin page) found1,qval = match(page, "var g_QS=\"([^\"]*)\"") found2,dval = match(page, "g_DO\[\"" & domain & "\"\]=\"([^\"]*)\"") action=dval & "?" & qval params["login"] = username params["passwd"] = password params["PwdPad"] = substring("IfYouAreReadingThisYouHaveTooMuchFreeTime",0,41-length(password)) #params["sec"] = "" #params["mspp_shared"] = "" #--- this cookie is added from an ad, but seems not to be necessary: #addcookie("MSNADS","UM=",".msn.com","/") #--- now submit the login form: status,page,headers = post(action,params) #--- still not there, the page contains a meta refresh, which we have to execute: found,url = match(page,"]*action=\"([^\"]*)\"[^>]*>(.*?)") delparams[folder] = getformfields(form) #--- get messages msgs1 = list() numfound,msgs1[].link,msgs1[].id,msgs1[].size.value,msgs1[].size.unit = matchall(page,msgspattern) foreach(msgs1,msg) msg.folder = folder #--- (Hotmail Staff messages are never read and thus always selected) if (!info.options["onlyUnread"].value || !find(msg.link,"msgread=1")) msgs[size(msgs)] = msg end end #--- unknown message sizes will automatically be set to 1kB end return true end sub receive(msg) local(status,page) msg.raw.link = msg.link & "&raw=1" msg.headers["folder"] = msg.folder #--- as reading the raw message does not mark the message read if (info.options["markRead"].value) #--- we have to retrieve the message the normal way, too status,page = get(msg.link) end return msg end sub delete(msgs) local(i,status,page,mydelparams,mydellink,msg) foreach(folders,folder) mydellink = dellink[folder] mydelparams = delparams[folder] isdelete = false foreach(msgs,msg) if (msg.folder == folder) mydelparams[msg.id] = "on" isdelete = true end end if (isdelete) mydelparams["_HMaction"] = "delete" status,page = post(mydellink,mydelparams) end end return true end sub loginForSend(username,password) local(ok) ok = login(username,password) return ok end sub send(msg) local(status,page) status,page = get(composelink) if (size(msg.attachments) > 0) warning("Attachments don't seem to work yet!") found,action,form = match(page,"]*\saction=\"([^\"]*)\"[^>]*>(.*?)") returnif(!found,false) params = getformfields(form) params["_HMaction"] = "AttachFile" status,page = post(action,params) foreach(msg.attachments,att) found,action,form = match(page,"]*\saction=\"([^\"]*)\"[^>]*>(.*?)") params = getformfields(form) attparams = map() attparams["attfile"] = att.link status,page = postmultipart(action,attparams,params) end found,action,form = match(page,"]*\saction=\"([^\"]*)\"[^>]*>(.*?)") returnif(!found,false) params = getformfields(form) attparams = map() status,page = postmultipart(action,attparams,params) end found,action,form = match(page,"]*\saction=\"([^\"]*)\"[^>]*>(.*?)") returnif(!found,false) params = getformfields(form) params["to"] = msg.to params["cc"] = msg.cc params["bcc"] = msg.bcc params["subject"] = msg.subject #params["outgoing"] = "on" #--- to switch on saving in Sent folder params["body"] = msg.text params["_HMaction"] = "Send" status,page = post(action,params) return true end sub logout local(status,page) status,page = get(logoutlink) end