Cliff Trapp <ctrapp(_at_)dogbert(_dot_)geg(_dot_)mot(_dot_)com> writes:
Please help me with the following scenario: I want to send a postscript
document to the distiller via email and have it return a PDF file. The
problem I get to is since I send just the body to the distiller, I lose
the return information formail needs. I know I need to RTFM, but I am
swamped and my head is spinning...and spinning..
...
PATH=$HOME/bin:/usr/bin:/usr/ucb:/bin:/usr/local/bin:.
Do you really need to do this? That's pretty close to the default, and
I have strong doubts about needing "." in there.
...
LOCKFILE=$HOME/.lockmail
You almost certainly don't want or need this
FORMAIL=/usr/local/bin/formail
Uh, the PATH variable was created for a reason: with it you don't need to
use fullpaths. Drop this line and just say "formail": /usr/local/bin is
already in your PATH.
:0 b
*
| $HOME/bin/distill | uuencode file.uu |$FORMAIL -r | /usr/lib/sendmail -oi -t
Okay, if we treat the distiller as a filter to feed the body through, then
we'll still have the original header to work with:
:0
* whatever conditions you want on doing this, plus a couple
* to avoid loops. I would suggest that one of your conditions
* be a size limit.
* ! ^FROM_DAEMON
* ! ^X-Loop: ctrapp(_at_)dogbert\(_dot_)geg\(_dot_)mot\(_dot_)com
{
# Distill the body. If the incoming message had a MIME-Version:
# header then we'll encode the outgoing PDF with MIME's base64
# encoding using mimencode. Otherwise, use uuencode (blech!).
# Note that $HOME/bin is in $PATH, so we can just call "distill"
:0 bf
* ^Mime-Version:.*1
| distill | mimencode -b
# Okay, now reverse the header. If we used MIME then we have to
# include the requisite MIME headers. The 'A' flag on the recipe
# 'chains it' off of the previous recipe.
:0 A
| formail -rtkb -A"X-Loop:
ctrapp(_at_)dogbert(_dot_)geg(_dot_)mot(_dot_)com" \
-I"Mime-Version: 1.0" -I"Content-Type: application/pdf" \
-I"Content-Transfer-Encoding: base64" | \
$SENDMAIL $SENDMAILFLAGS -t
# Okay, if got here, then it (the incoming message) didn't have
# a Mime-Version: header (or it didn't look like version 1).
# Uuencode and then send it.
:0 bf
| distill | uuencode file.pdf
:0
| formail -rtkb -A"X-Loop:
ctrapp(_at_)dogbert(_dot_)geg(_dot_)mot(_dot_)com" | \
$SENDMAIL $SENDMAILFLAGS -t
}
Does that make sense?
Philip Guenther