Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Deleting Email. Review this Script?

From: tim-johnsons:web at: 11-Aug-2006 13:12

Hi: For several years, I've been using this script to run as both a CGI process and a cron process from some server while I am traveling. What it does is delete any email not sent to my email address. I.E. any mail sent to a mailing list is deleted. Doesn't take care of spam, but I can handle that thru webmail. The problem is that when I run this manually, I note that have to run it more that once to "clean out" the email. I'm presenting the script (with user and password obfuscated) for review perhaps someone can point out code changes that will delete all ML messages in one pass. TIA Tim ;; Code follows #!/usr/bin/rebol -cs REBOL[ Title: "popscan" Date: File: %popscan.r Purpose: {scan mailbox for mailing list messages. Delete where found.} URL: http://localhost/cgi-bin/AIS/popscan.r ] ;; ======================================================= print "Content-Type: text/html^/" ; email-address: "tim-johnsons-web.com" user: "********************" pwd: "******************" server: "postman.johnsons-web.com" ;; ======================================================= print "<pre>" url: to-url rejoin ["pop://" user ":" pwd "-" server] ?? url main: func[ /local mailbox deleted msg recipient ML ][ deleted: 0 ML: false print "Connecting ......" mailbox: open url print rejoin[(length? mailbox) " messages found."] while [not tail? mailbox][ msg: import-email first mailbox ; imports the email message recipient: to-string msg/to ; sets the recipient ('TO:') value in the message either all[(recipient = email-address) ][ print "<font color=^"blue^">------- KEEPING ----------------------" print rejoin[ "From: " msg/from newline "Subject: " msg/subject </font>] ][ print "<font color=^"red^">------- DELETING ----------------------" print rejoin[ "From: " msg/from newline "Subject: " msg/subject </font>] ML: true deleted: deleted + 1 ] mailbox: next mailbox ; next message if any[ML][ print rejoin["deleting number " deleted] remove skip mailbox -1 ML: false ] ] print rejoin[deleted " message(s) were deleted"] ] main print "</pre>" -- Tim Johnson <tim-johnsons-web.com> http://www.alaska-internet-solutions.com