Dallman Ross wrote,
| I am at a new job where I can't pop3 my private mail right now.
| So I am trying to set up a recipe to do the following:
|
| (a) Move my current mail spool somewhere temporary
| (b) Use the convention
|
| cat mailfile | formail -s sendmail my(_at_)work(_dot_)account
First, thwack for the useless cat. We can't have that.
| (or something equally useful) to send the mail now
| sitting in the temporary location
| I figure that each time I invoke this recipe (from work) and move the
| spool it can overwrite the temporary file I had created from the last
| time, if it is still there.
Once you have it working reliably you probably wouldn't need a temporary
file; just a good locking scheme.
| I also was considering that I keep my .procmailrc readable, and many
| look at it. Someone might spoof me and invoke the recipe. This is not
| so dangerous, though, because it will only send my mail to work. If I'm
| not there, I won't see it until the next time I get to work. But that
| is a not-very-likely scenario anyway.
Simple solution: keep a password in a separate file with 600 perms; let's
call it $HOME/.mailbox/.forwardpass, containing this:
SPOOL_FORWARD_PASSWORD=[whatever you choose]
Then let your .procmailrc learn it with INCLUDERC=.forwardpass. Don't
put in a procmailrc routine to update it remotely if you don't need to:
update it manually by logging in when you want to change the password.
Then require that the message contain -- in the body, in a header field you
pick, wherever (not the subject, though, if your procmail logfile is also
readable) -- $SPOOL_FORWARD_PASSWORD.
| Here's a stab that I'm a little too afraid to test until I get some
| feedback. (Also, it might not work, because my "procmailese" is so
| rusty.):
|
| # On-Demand Mail Delivery
| cd $HOME/.mailbox
| # I think word after last colon in first line is naming
| # convention for local lockfile? ["dross" is a pun on
| # my work userid and the temporary purpose of the file]
| :0 Dh:dross # D says case-sensitive; I think h says ignore header(?)
| * ^From +d(man|ross)@
| * ^Subject: +#FWMAIL
| | ( mv $ORGMAIL dross;
| cat dross ) | $FORMAIL -s $SENDMAIL dross(_at_)work(_dot_)address
|
| ($ORGMAIL, $SENDMAIL and $FORMAIL are defined up-top)
| Reactions? Oh, this is under 3.11 pre 4. Another consideration: what
| will happen if my mail spool is empty when I invoke the recipe?
Good thinking. Let's allow for that.
MAILDIR=$HOME/.mailbox # this is how to make procmail cd
:0D
* ^From +d(man|ross)@
* ^Subject: +#FWMAIL
{
INCLUDERC=.forwardpass
:0:
* $ ! ^X-Forwarding-Password: *$SPOOL_FORWARD_PASSWORD$
spoofattempts
LOCKFILE=$ORGMAIL$LOCKEXT # regional lockfile; we'll be using it until
procmail exits, so we don't need to unset LOCKFILE to remove it
:0c: # if you want to keep copies of the trigger messages
forwarding_requests
:0frw
* ? test -s $ORGMAIL # if $ORGMAIL is non-empty
| cat $ORGMAIL
:0Arc
| formail -I "X-Forwarded: from $LOGNAME(_at_)$HOST" -es \
$SENDMAIL $SENDMAILFLAGS my(_at_)work(_dot_)account
:0Arc # for safety during testing; once it's working, drop this step
.sentspool # append to backup; | cat > .sentspool to clobber backup
:0Ahi
| true > $ORGMAIL # safer to empty it than to rm it
:0bfw
| echo "\$ORGMAIL was empty. There was nothing to forward."
:0hfw # not to get return address but to add Re: and remove
| formail -r # old From: and Date: and remove X-Forwarding-Password:
:0
! my(_at_)work(_dot_)account
}
There are other approaches, of course.