From: "matt" <matt@proweb.co.uk>
To: <9fans@cse.psu.edu>
Subject: [9fans] pop3 collector
Date: Mon, 22 Jul 2002 12:35:04 +0100 [thread overview]
Message-ID: <00ae01c23173$d3f53de0$6501a8c0@KIKE> (raw)
[-- Attachment #1: Type: text/plain, Size: 803 bytes --]
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
[-- Attachment #2: mailcollector --]
[-- Type: application/octet-stream, Size: 2354 bytes --]
#!/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.
reply other threads:[~2002-07-22 11:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00ae01c23173$d3f53de0$6501a8c0@KIKE' \
--to=matt@proweb.co.uk \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).