procmail
[Top] [All Lists]

Re: Sending warning of virus via procmail

2003-10-01 21:36:45
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