REBOL [
    title: "WAP Mail Reader CGI"
    date: 10-Aug-2010
    file: %wap-mail-reader.r
    author:  Nick Antonaccio
    purpose: {
        Read email using your WAP cell phone browser.
    }
]

#!./rebol276 -cs
REBOL [title: "WAP Mail Reader CGI"]
submitted: decode-cgi system/options/cgi/query-string
prin {Content-type: text/vnd.wap.wml^/^/}
prin {^/}
prin {^/}
accounts: [
    ["pop.server" "smtp.server" "username" "password" you@site.com]
    ["pop.server2" "smtp.server2" "username" "password" you@site2.com]
    ["pop.server3" "smtp.server3" "username" "password" you@site3.com]
]
if ((submitted/2 = none) or (submitted/2 = none)) [   
    print {

} print {Account: Submit } print {

} quit ] if submitted/4 = "readselect" [ t: pick accounts (to-integer submitted/2) system/schemes/pop/host: t/1 system/schemes/default/host: t/2 system/schemes/default/user: t/3 system/schemes/default/pass: t/4 system/user/email: t/5 prin {

} prin rejoin [{}] prin { Submit

} quit ] if submitted/2 = "display" [ t: pick accounts (to-integer submitted/6) system/schemes/pop/host: t/1 system/schemes/default/host: t/2 system/schemes/default/user: t/3 system/schemes/default/pass: t/4 system/user/email: t/5 prin {

} mail: read to-url join "pop://" system/user/email foreach message mail [ pretty: import-email message if pretty/subject = submitted/4 [ replace/all pretty/content {"} {} replace/all pretty/content {&} {} replace/all pretty/content {3d} {} strip: copy "" foreach item (load/markup pretty/content) [ if ((type? item) = string!) [strip: join strip item] ] prin strip ] ] print {

} quit ]