# Mail.com # supports receiving and sending of mails with attachments # # @Requires: 1.1 RC2 # @Version: 0.5.4 # avoid getting the attachment info into the message body, # remove size information after picture attachments # fix retrieval of inline pictures # @Version: 0.5.3 # better character set decoding # @Version: 0.5.2 # fixed send link (thanks to chris gadd) # @Version: 0.5.1 # german texts (with MrPostman 1.2.2+) # @Version: 0.5 # support for @usa.com accounts at mail.usa.com # support for asiamail: @asiamail.com, @138mail.com, @koreanmail.com, @mailasia.com, @mailpanda.com # (tested with mailpanda.com in english) # @Version: 0.4.6 # fixed a bug where the terminating ; was included in the charset. # defined variables as local in receive (possible header problems). # @Version: 0.4.5 # fixed a bug which caused the date to be ommitted # @Version: 0.4.4 # retrieve all message headers # @Version: 0.4.2 # started enabling login on other sites, e.g. for some usa.com accounts, not yet finished # @Version: 0.4.1 # removed wrong help link # @Version: 0.4 # inline pictures # @Version: 0.3 # added delays (sleep) as otherwise mail.com returns errors after a while # @Version: 0.2.2 # webmail update: updated check for promotion page # ... sub getInfo local(info) info.name = "maildotcom" info.authors[0] = "Frank0 Brain " info.authors[1] = "Martin Vlcek " info.version = "0.5.4" info.updateService = "" info.documentationLink = "" return info end sub getExtensions local(ext) ext = list("@mail.com", "@earthling.net", "@email.com", "@iname.com", "@cheerful.com") ext = join(ext, "@consultant.com", "@europe.com", "@europe.com", "@mindless.com") ext = join(ext, "@myself.com", "@post.com", "@techie.com", "@usa.com") ext = join(ext, "@writeme.com", "@2die4.com", "@artlover.com", "@bikerider.com") ext = join(ext, "@catlover.com", "@cliffhanger.com", "@cutey.com", "@doglover.com") ext = join(ext, "@gardener.com", "@hot-shot.com", "@inorbit.com", "@loveable.com") ext = join(ext, "@mad.scientist.com", "@playful.com", "@poetic.com", "@popstar.com") ext = join(ext, "@saintly.com", "@seductive.com", "@soon.com", "@whoever.com") ext = join(ext, "@winning.com", "@witty.com", "@yours.com", "@africamail.com") ext = join(ext, "@arcticmail.com", "@asia.com", "@australiamail.com", "@europe.com") ext = join(ext, "@japan.com", "@samerica.com", "@usa.com", "@berlin.com") ext = join(ext, "@dublin.com", "@london.com", "@madrid.com", "@moscowmail.com") ext = join(ext, "@munich.com", "@nycmail.com", "@paris.com", "@rome.com") ext = join(ext, "@sanfranmail.com", "@singapore.com", "@tokyo.com") ext = join(ext, "@accountant.com", "@adexec.com", "@allergist.com", "@alumnidirector.com") ext = join(ext, "@archaeologist.com", "@chemist.com", "@clerk.com", "@columnist.com") ext = join(ext, "@comic.com", "@consultant.com", "@counsellor.com", "@deliveryman.com") ext = join(ext, "@doctor.com", "@dr.com", "@engineer.com", "@execs.com") ext = join(ext, "@financier.com", "@geologist.com", "@graphic-designer.com", "@hairdresser.net") ext = join(ext, "@insurer.com", "@journalist.com", "@lawyer.com", "@legislator.com") ext = join(ext, "@lobbyist.com", "@minister.com", "@musician.org", "@optician.com") ext = join(ext, "@pediatrician.com", "@presidency.com", "@priest.com", "@programmer.net") ext = join(ext, "@publicist.com", "@realtyagent.com", "@registerednurses.com", "@repairman.com") ext = join(ext, "@representative.com", "@rescueteam.com", "@scientist.com", "@sociologist.com") ext = join(ext, "@teacher.com", "@techie.com", "@umpire.com", "@innocent.com") ext = join(ext, "@cyberdude.com", "@cybergal.com", "@technologist.com", "@unforgettable.com") #--- other domains not directly served by mail.com ext = join(ext, getOtherExtensions()) return ext end sub getOtherExtensions #--- global variables asiamail_ext = list("@138mail.com", "@asiamail.com", "@koreanmail.com", "@mailasia.com", "@mailpanda.com") #--- return all additional extensions return asiamail_ext end sub init(domain) getOtherExtensions() #--- set some basic settings to allow MrPostman doing some conversions, ... #--- the variables need to be global size.locale = "en" size.unit = map("b",1,"k",1024,"m",1024*1024,"M",1024*1024) loginurl = "http://www.mail.com/scripts/common/proxy.main" #--- last try to get message - e.g. for USA.COM: messagepattern = "\s*(.*?)]*name=\"inBoxMessages\"") msgpat = "href=\"([^\"]*read.mail\?.*?msg_uid=([0-9_-]+)&[^\"]*)\".*?]*>(\d+)([a-zA-Z]*)<" numfound,msgs[].link,msgs[].id,msgs[].size.value,msgs[].size.unit = matchall(page,msgpat) if (numfound <= 0) #--- format for e.g. usa.com: msgpat = "href=\"Javascript:readPopUpMail\('([^']*read.mail\?.*?msg_uid=([0-9_-]+)&[^']*)'.*?]*>]*>(\d+)([a-zA-Z]*)<" numfound,msgs[].link,msgs[].id,msgs[].size.value,msgs[].size.unit = matchall(page,msgpat) end #--- further pages: nextpagepattern = "href=\"([^\"]*ShowFolder[^\"]*next=1[^\"]*)\"" found,nextpagelink = match(page,nextpagepattern) while (found) msgs1 = list() status,page = mget(nextpagelink) numfound,msgs1[].link,msgs1[].id,msgs1[].size.value,msgs1[].size.unit = matchall(page,msgpat) msgs = join(msgs,msgs1) found,nextpagelink = match(page,nextpagepattern) end return true end sub receive(msg) local(status,page,found,headers) local(attachpattern,numfound,attachment,inlineattachments) sleep(500) status,page = mget(msg.link & "&mhead=f") found,msg.from = match(page,"]*>From:\s*(?:)?(?:)?\s*]*>([^<]*)<") if (!found) found,msg.from = match(page,"From:\s*(?:)?(?:)?\s*]*>([^<]*)<") errorif(!found,"Can't read message '" & msg.id & "'") end found,msg.to = match(page,"]*>To:\s*(?:)?\s*]*>([^<]*)<") found,msg.cc = match(page,"]*>CC:\s*(?:)?\s*]*>([^<]*)<") # Never going to have bcc unless &mhead=f option used to retrieve msg... FAH found,msg.bcc = match(page,"]*>Bcc:\s*(?:)?\s*]*>([^<]*)<") found,msg.date = match(page,"]*>Date:\s*(?:)?\s*]*>([^<]*)<") found,msg.subject = match(page,"]*>Subject:\s*(?:)?\s*]*>([^<]*)<") #--- need to get charset for international mails found,msg.charset = match(page,"Content-Type:[^<]*charset=(?:\"|")?([^&\"\s<;]*)[&\"\s<;]",true) #--- get all headers - only effective in 1.1RC2+ numfound,headers[].name,headers[].value = matchall(page,"([^:]*): ([^<]*)
") msg.headers = map(headers[].name,headers[].value,true) #--- now get the actual message #--- is it a html mail? found,msg.text = match(page,"\s*(.*)",true) if (!found) #--- maybe it's a text message... found,msg.text = match(page,"(
.*?
)",true) if (!found) #--- no pre and xhtml tags found, try everything in obmessage span #--- brute force - FAH #found,msg.text = match(page,"()",true) found,msg.text = match(page,"(.*)",true) if (!found) #--- another possible pattern, configured in init: found,msg.text = match(page,messagepattern) if (!found) msg.text = "ATTENTION: Message content not found - check your account with your browser!" end end end end msg.text = "\n" & msg.text & "\n" #--- use html mimetype also for text mail, as there might be html tags and entities! msg.mimetype = "text/html" #--- get attachments #--- remove everything after comma of attachment text, it is e.g. the size of pictures attachpattern = "]*><[^>]*>([^<,]*)(?:,[^<]*)?<" numfound,msg.attachments[].link,msg.attachments[].text = matchall(page,attachpattern,true) #--- find inline pictures in text: inlineattachments = list() attachpattern = "]*src=\"([^\"]*parts?no=([^\"&]+)[^\"]*)\"" numfound,inlineattachments[].link,inlineattachments[].id = matchall(msg.text,attachpattern,true) foreach(inlineattachments,attachment) attachment.text = attachment.id msg.text = replace(msg.text,"src=\"[^\"]*parts?no="&attachment.id&"[^\"]*\"","src=\"cid:"&attachment.id&"\"") end msg.attachments = join(msg.attachments,inlineattachments) return msg end sub delete(msgs) local(params,msg,status,page) params["folder"] = "INBOX" params["order"] = "newest" params["changeview"] = "0" params["mview"] = "a" params["mstart"] = "1" params["flags"] = "" params["views"] = "a" params["folder_name"] = "Trash" params["matchfield"] = "" params["mpat"] = "" #--- the following parameters are set in the Javascript function DeleteMail: params["delete_selected"] = "yes" params["move_selected"] = "" params["flag_selected"] = "" foreach(msgs,msg) params["sel_" & msg.id] = "ON" end status,page = mpost(deletelink,params) #--- TODO: check success return true end sub loginForSend(username,password) return login(username,password) end sub send(msg) status,page = mget(sendlink) #--- get compose message form: composeformpattern = "(]*name=\"composeForm\".*?)" found,form,action = match(page,composeformpattern) params = getformfields(form) if (size(msg.attachments)>0) params["att"] = "show" attachformpattern = "(]*name=\"attachmentForm\".*?)" status,page = mpost(action,params) found,form,action = match(page,attachformpattern) params = getformfields(form) foreach (msg.attachments,attachment) params["att"] = "upload" params["filename"] = attachment.text fileparams["attachment"] = attachment.link status,page = postmultipart(action,fileparams,params) found,form,action = match(page,attachformpattern) params = getformfields(form) end params["att"] = "done" fileparams = map() status,page = postmultipart(action,fileparams,params) found,form,action = match(page,composeformpattern) params = getformfields(form) end params["to"] = msg.to params["cc"] = msg.cc params["bcc"] = msg.bcc params["subject"] = msg.subject params["body"] = msg.text params["send"] = "Send" status,page = mpost(action,params) #--- TODO: check success return true end sub logout get(trim(logoutlink)) end #--- helper functions sub clickad(status,page,headers) local(found,contlink,framelink) #found,contlink = match(page,"if \(agentP==1\) document.location.href=\"([^\"]*)\"") found,contlink = match(page,"if \(+agentP.*? document.location.href=\"([^\"]*)\"") if (found) sleep(500) #--- advertisement status,page,headers = get(contlink) #--- now we should be on the main page again - get the important frame: found,framelink = match(page,"src=\"([^\"]*)\"\s+name=\"mailcomframe\"") status,page,headers = get(framelink) end return status,page,headers end sub mget(url) local(status,page,headers) status,page,headers = get(url) return clickad(status,page,headers) end sub mpost(url,params) local(status,page,headers) status,page,headers = post(url,params) return clickad(status,page,headers) end
.*