From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <00ae01c23173$d3f53de0$6501a8c0@KIKE> From: "matt" To: <9fans@cse.psu.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_00A9_01C2317C.34817400" Subject: [9fans] pop3 collector Date: Mon, 22 Jul 2002 12:35:04 +0100 Topicbox-Message-UUID: d3815db6-eaca-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. ------=_NextPart_000_00A9_01C2317C.34817400 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Here's the first "working" script that mounts a remote mail system and then transfers the mail from there to the local mail system. It uses a control file with the username and passwords to use in the form proto domain user password at the moment the only supported proto is pop the default location for this file is /usr/$user/mailcollector.boxes the mail is injected from $user I've only run this for a day or so but no problems so far. of course YMMV usage : mailcollector [-f mailboxfile] [-k] -f = use non-default mailbox info file -k = leave messages on the server It uses and abuses factotum but as far as I could tell factotum will only store one un/pw per service per domain which fails you when you have multiple pop boxs on the same domain. M ------=_NextPart_000_00A9_01C2317C.34817400 Content-Type: application/octet-stream; name="mailcollector" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mailcollector" #!/bin/rc=0A= =0A= # This script utilises the upas/fs mounted mail system to mount a remote = mailbox and then =0A= # transfer the messages using the local smtp process.=0A= =0A= # matt@proweb.co.uk=0A= # 16/7/2002=0A= =0A= =0A= # run our own copy of factotum so we dont use the current process's one=0A= auth/factotum=0A= =0A= # we're going to need a clean mail too=0A= upas/fs=0A= =0A= # read the parameters from /usr/$user/pop3=0A= # the format of which is line separated records of space or tab = separated fields :=0A= # protocol domain username password=0A= # Example :=0A= # pop pop3.aol.om connie secret=0A= # =0A= # $key(1) $key(2) $key(3) $key(4)=0A= # =0A= =0A= pwfile =3D /usr/$user/mailcollector.boxes=0A= keep =3D 0=0A= # -f pwfile <- use a different pw file=0A= while(~ $1 -*){=0A= switch($1){=0A= case -f:=0A= shift=0A= pwfile =3D $1=0A= case -k:=0A= keep =3D '1'=0A= }=0A= shift=0A= }=0A= =0A= {=0A= key =3D `{read}=0A= num_msgs =3D 0=0A= while(test $#key '!=3D' '0') { # die when null/blank line=0A= switch($key(1)) {=0A= # made it a switch for expansion and comments =0A= case pop :=0A= # tell stdout what we're doing=0A= echo $key(3) at $key(2)=0A= =0A= # insert a key into the local factotum =0A= echo 'key proto=3Dpass service=3D' ^$key(1) ^' dom=3D' ^$key(2) ^' = user=3D' ^$key(3) ^' !password=3D' ^$key(4) > /mnt/factotum/ctl=0A= =0A= # open the mailbox, it get's mounted as /mail/fs/$key(3) =0A= echo 'open /pop/'^$key(2) ^' ' ^$key(3) > /mail/fs/ctl=0A= =0A= =0A= msgs =3D /mail/fs/$key(3)=0A= if (test -d $msgs) { # make sure it's a directory (to skip = ctl)=0A= for (msg in `{ls $msgs}) { # get the message list=0A= if (test -d $msg) { # if message is directory=0A= cat $msg/raw | upas/send -r -b $user # get upas to send it to = $user from $user=0A= =0A= num_msgs =3D `{echo $num_msgs + 1 | bc}=0A= echo From: `{cat $msg/from} # Tell stdout=0A= echo Subject : `{cat $msg/subject}=0A= if (test $keep '=3D' '0')=0A= rm $msg # delete message from the remote server=0A= }=0A= =0A= }=0A= } =0A= if not {=0A= echo no mail # poor you, at least you got no spam=0A= }=0A= echo 'close ' ^$key(3) > /mail/fs/ctl # close the mailbox=0A= =0A= # delete the key from factotum so that we can process multiple pop3 = boxes on the same domain=0A= echo 'delkey proto=3Dpass service=3D' ^$key(1) ^' dom=3D' ^$key(2) ^' = user=3D' ^$key(3) > /mnt/factotum/ctl=0A= }=0A= key =3D `{read}=0A= }=0A= =0A= } < $pwfile=0A= =0A= echo $num_msgs mails processed.=0A= =0A= =0A= =0A= =0A= ------=_NextPart_000_00A9_01C2317C.34817400--