View script | License | Download script | History | Other scripts by: notchent |
28-Mar 11:29 UTC
[0.055] 13.294k
[0.055] 13.294k
Archive version of: core-email.r ... version: 1 ... notchent 9-Oct-2009Amendment note: new script || Publicly available? Yes REBOL [ File: %core-email.r Date: 9-Oct-2009 Title: "Core Email" Author: Nick Antonaccio Purpose: { A simple email program that can run in REBOL/Core - entirely at the command line (no VID GUI components or View graphics are required). You can store configuration information for as many email accounts as you'd like in the "accounts" block, and easily switch between them at any point in the program. Taken from the tutorial at http://musiclessonz.com/rebol.html } ] 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] ] cls: does [prin "^(1B)[J"] a-line:{*****************************************************************} b-line: replace/all copy a-line "*" "-" select-account: does [ cls print b-line forall accounts [ print rejoin ["^/" index? accounts ": " last first accounts] ] print join "^/" b-line selected: to-integer ask "^/Select an account #: " t: pick accounts selected 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 ] send-email: does [ cls print rejoin [b-line "^/^/Send Email:^/^/" b-line] addr: ask "^/^/Recipient Email Address: " subject: ask "^/Email Subject: " print {^/Body (when finished, type "end" on a seperate line):^/} print join b-line "^/" body: copy "" get-body: does [ body-line: ask "" if body-line = "end" [return] body: rejoin [body "^/" body-line] get-body ] get-body print rejoin ["^/" b-line "^/^/Sending..."] send/subject to-email addr body subject cls print "Sent^/" wait 1 ] read-email: does [ cls print "One moment..." mail: open to-url join "pop://" system/user/email while [not tail? mail] [ cls print "Reading...^/" prin rejoin [ first mail "^/^/" b-line {^/The message above is #} length? mail { from: } system/user/email {^/} b-line {^/} {^/[ENTER]: Go Forward (next email)^/} {^/ "b": Go Backward (previous email)^/} {^/ "d": Delete current email^/} {^/ "q": Quit this mail box^/} {^/ Any #: Skip forward or backward this # of messages^/} {^/} b-line {^/^/Enter Command: } ] switch/default mail-command: ask "" [ "" [mail: next mail] "b" [mail: back mail] "d" [remove mail cls print "Email deleted!^/" wait 1] "q" [close mail cls print "Mail box closed^/" wait 1 break] ] [mail: skip mail to-integer mail-command] if (tail? mail) [mail: back mail] ] ] select-account forever [ cls print b-line print rejoin [ {^/"r": Read Email^/} {^/"s": Send Email^/} {^/"c": Choose a different mail account^/} {^/"q": Quit^/} ] print b-line response: ask "^/Select a menu choice: " switch response [ "r" [read-email] "s" [send-email] "c" [select-account] "q" [cls print rejoin [b-line"^/^/DONE!^/^/"b-line] wait .5 quit] ] ] |