Thanks for in input Scott, I had actually tried it with an extra echo ""; \
between the Subject: and body thinking that was the _right_ way to do it,
however, I ended up with one line of headers in my body; the "X-ClamAV:
clean" line that is the "good to go" for this particular email. (not the
original X-ClamAV: <Virus>) Strangely, it's not the last header line of the
raw email when I discected it to see why I had that line.
It seems to me you are correct, formail is the way to go...it'll just take
some messing around to figure out what a sane formail will look like to put
all this stuff together.
My thought on the 'w' was to avoid the fork that seemed to happen when I
left it out and was debugging. Actually, I could probably put a :0h there
and be done since I'm not using any of the body of the original message...I
think.
Thanks for the input,
Rob
On Wed, 1 Oct 2003 22:25:33 -0600, Scott Wiersdorf wrote
On Wed, Oct 01, 2003 at 08:00:00PM -0600, Rob Lists wrote:
Greetings,
:0w
{
# Grab the entire header for the body of the message
# Grab the Virus name for the Subject line.
HEADER = `formail -X "" `
VIRUS = `formail -xX-ClamAV`
:0
| ( echo "From: Postmaster(_at_)dympna(_dot_)com"; \
echo "To: $LOGNAME(_at_)dympna(_dot_)com"; \
echo "Subject: ** Virus eMail with $VIRUS"; \
echo "No auto-reply was sent to the originator of this virus";\
echo "infected email. You may with to contact the person in";\
echo "the >From: line below."; \
echo " ";\
echo "Following are the headers that were extracted from the
email:";\
echo " ";\
echo "$HEADER" ) | $SENDMAIL -oi -t
}
:0:
$VIRUS_FOLDER
}
Functionally, this completes just fine and does exactly what I want.
However, I'm getting this message from the verbose logging:
procmail: Error while writing to " ( echo "From:
postmaster(_at_)dympna(_dot_)com";
\
I don't understand what the error is from. It completes, what am I
doing
wrong?
I think the error is coming from sendmail. Your message doesn't have
any blank line after 'Subject' and the subsequent lines aren't RFC822
compliant. Try putting an "echo" after "echo Subject: ..." and see if
sendmail gets happy. If that doesn't work, try simply cat'ing a saved
mail message to sendmail instead to see if sendmail stops
complaining. If that fixes it, that means you'll have to do more work
to get your 'echo' lines correct. May I recommend using formail to
generate most of your headers? It does a good job.
Also (a nit) I don't see a filter anywhere, so the 'w' flag at the
top probably isn't necessary. You'll usually see it in conjunction with
'f' (procmailrc).
Also, I'd love to hear other ways of doing this...I came up with this
solution on my own after trying out a couple of pipes to external
scripts.
I'm sure it's not the most elegant or possibly even correct! I just
-had-
to have some form of notification.
You might consider using formail (see the formail manpage) for
generating your headers; it will be less work and probably more RFC
correct.
Scott
--
Scott Wiersdorf
scott(_at_)perlcode(_dot_)org
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail