#!/bin/rc # This script utilises the upas/fs mounted mail system to mount a remote mailbox and then # transfer the messages using the local smtp process. # matt@proweb.co.uk # 16/7/2002 # run our own copy of factotum so we dont use the current process's one auth/factotum # we're going to need a clean mail too upas/fs # read the parameters from /usr/$user/pop3 # the format of which is line separated records of space or tab separated fields : # protocol domain username password # Example : # pop pop3.aol.om connie secret # # $key(1) $key(2) $key(3) $key(4) # pwfile = /usr/$user/mailcollector.boxes keep = 0 # -f pwfile <- use a different pw file while(~ $1 -*){ switch($1){ case -f: shift pwfile = $1 case -k: keep = '1' } shift } { key = `{read} num_msgs = 0 while(test $#key '!=' '0') { # die when null/blank line switch($key(1)) { # made it a switch for expansion and comments case pop : # tell stdout what we're doing echo $key(3) at $key(2) # insert a key into the local factotum echo 'key proto=pass service=' ^$key(1) ^' dom=' ^$key(2) ^' user=' ^$key(3) ^' !password=' ^$key(4) > /mnt/factotum/ctl # open the mailbox, it get's mounted as /mail/fs/$key(3) echo 'open /pop/'^$key(2) ^' ' ^$key(3) > /mail/fs/ctl msgs = /mail/fs/$key(3) if (test -d $msgs) { # make sure it's a directory (to skip ctl) for (msg in `{ls $msgs}) { # get the message list if (test -d $msg) { # if message is directory cat $msg/raw | upas/send -r -b $user # get upas to send it to $user from $user num_msgs = `{echo $num_msgs + 1 | bc} echo From: `{cat $msg/from} # Tell stdout echo Subject : `{cat $msg/subject} if (test $keep '=' '0') rm $msg # delete message from the remote server } } } if not { echo no mail # poor you, at least you got no spam } echo 'close ' ^$key(3) > /mail/fs/ctl # close the mailbox # delete the key from factotum so that we can process multiple pop3 boxes on the same domain echo 'delkey proto=pass service=' ^$key(1) ^' dom=' ^$key(2) ^' user=' ^$key(3) > /mnt/factotum/ctl } key = `{read} } } < $pwfile echo $num_msgs mails processed.