# Gossamer Mail (gossamer-threads.com) # supports receiving of mail with attachments # # @Requires: 1.1 beta3 # @Version: 1.0.1 # german texts (with MrPostman 1.2.2+) # @Version: 1.0 sub getInfo local(info) info.name = "gossamer" info.authors[0] = "Martin Vlcek " info.version = "1.0.1" info.updateService = "" info.documentationLink = "" info.options["extensions"].order = 1 info.options["extensions"].value = "@domain.com" info.options["extensions"].label = "Extensions" info.options["extensions"].description = "Extensions (including @) separated by ','" info.options["link"].order = 2 info.options["link"].value = "http://www.somewhere.com/login.cgi?t=template;domain=domain.com" info.options["link"].label = "Login Link" info.options["link"].description = "The HTML page with the login form" #--- german texts info.options["extensions"].de.label = "E-Mail-Endungen" info.options["extensions"].de.description = "E-Mail-Endungen (mit @) getrennt durch ','" info.options["link"].de.label = "Anmelde-Link" info.options["link"].de.description = "Die HTML-Seite mit dem Anmeldeformular" return info end sub getExtensions # more fault tolerant in regard to separators than specified in description return split(info.options["extensions"].value,"[\s,;]+") end sub login(username,password) local(found,user,domain,status,page,form,action,params) found,user,domain = match(username,"\A(.*)@(.*)\Z") found,template = match(info.options["link"].value,"[\?&]t=([^&])(?:&|\Z)") #--- after setting the base url relative links will be done correctly: setbaseurl(info.options["link"].value) #--- set some basic settings to allow MrPostman do some conversions, ... size.locale = "en" size.unit = map("B",1,"KB",1024,"MB",1024*1024,"GB",1024*1024*1024) date.locale = "en" date.format = "EEEE, MMMM d, yyyy HH:mm:ss a" #--- let's log in: status,page = get(info.options["link"].value) found,form,action = match(page,"(]*action=\"([^\"]*)\".*?)") params = getformfields(form) params["domain"] = domain params["username"] = user params["password"] = password params["cookie"] = "No" status,page = post(action,params) found,logoutlink = match(page,"href=\"([^\"]*logout.cgi[^\"]*)\"") found,sid = match(page,"name=\"sid\" value=\"([^\"]*)\"") return page end sub loginForReceive(username,password) local(page,msgpat,numfound) page = login(username,password) #--- we are at the inbox page: get the messages msgpat = "href=\"([^\"]*msgtrack_id=(\d+);[^\"]*)\".*?>([\d\.]+)\s+(.?B)<" numfound,msgs[].link,msgs[].id,msgs[].size.value,msgs[].size.unit = matchall(page,msgpat) return true end sub receive(msg) info("Getting message " & msg.id & "...") status,page = get(msg.link) msg.mimetype = "text/plain" found,msg.from = match(page,">From:<.*?>([^<]*)") found,msg.to = match(page,">To:<.*?([^<]*)<") found,msg.cc = match(page,">CC:<.*?([^<]*)<") found,msg.date = match(page,">Date:<.*?([^<]*)<") found,msg.subject = match(page,">Subject:<.*?([^<]*)<") found,msg.text = match(page,"
(.*)
") if (!found) #--- HTML message found,msg.text = match(page,"id=\"mailbody\">(.*?)\s*\s*") msg.text = "/n" & msg.text & "\n" msg.mimetype = "text/html" end attachpat = "href=\"([^\"]*do=messages-print_attach[^\"]*)\"[^>]*>([^<]*)