As a Procmail newbie, I am working on some recipes that can match certain
attachments by file names.
If matched, message should be trashed into a specified folder (and not
delivered to the intended user) and an autoreply should be created and sent
back to the originator of the message, letting them know that we do not allow
messages with certain attachments extensions (doc etc).
I can successfully match the attachment and save to the specified folder and
also generate the autoreply, but it is not working 100%.
- It seems as if the message is still delivered to the recipient, which I do
not understand, it should only be kept in /usr/mailfilters/doc.
- Looking at the log, there is an error 'procmail: Error while writing to "
(formail -rt ; \', what does this mean?
- How can I avoid two copies being saved, i.e. once a match save to
/usr/mailfilters/doc and generate autoreply.
Would appreciate if someone could give me a push in the right direction.
Thanks in advance,
Niklas Palmqvist
---------------
The code:
LOGFILE=/var/log/procmail
VERBOSE=on
LOGABSTRACT=all
:0
{
# Get the subject.
SUBJ=`formail -c -xSubject: | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
# Get the sender.
FROM=`formail -rt -xTo: | sed -e 's/[;\`\\]/ /g' \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
# Match on name.
:0 Bc:
* .*name=.*\.doc
/usr/mailfilters/doc
# Match on filename.
:0 Bc:
* .*filename=.*\.doc
/usr/mailfilters/doc
:0
| (formail -rt ; \
echo "Your e-mail was bounced!" \
) | sendmail -oi -t
}
Extract from the log:
procmail: [3586] Fri Feb 15 10:04:21 2002
procmail: Assigning "LOGABSTRACT=all"
procmail: Executing "formail -c -xSubject: | sed -e 's/^[ ]*//g' -e 's/[
]*$//g'"
procmail: Assigning "SUBJ=Test..."
procmail: Executing "formail -rt -xTo: | sed -e 's/[;`\]/ /g' |
expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'"
procmail: Assigning "FROM=npalmqvist(_at_)shipco(_dot_)com"
procmail: Match on ".*name=.*\.doc"
procmail: Locking "/usr/mailfilters/doc.lock"
procmail: Assigning "LASTFOLDER=/usr/mailfilters/doc"
procmail: Opening "/usr/mailfilters/doc"
procmail: Acquiring kernel-lock
From npalmqvist(_at_)shipco(_dot_)com Fri Feb 15 10:04:21 2002
Subject: Test...
Folder: /usr/mailfilters/doc
21698
procmail: Unlocking "/usr/mailfilters/doc.lock"
procmail: Match on ".*filename=.*\.doc"
procmail: Locking "/usr/mailfilters/doc.lock"
procmail: Assigning "LASTFOLDER=/usr/mailfilters/doc"
procmail: Opening "/usr/mailfilters/doc"
procmail: Acquiring kernel-lock
From npalmqvist(_at_)shipco(_dot_)com Fri Feb 15 10:04:21 2002
Subject: Test...
Folder: /usr/mailfilters/doc
21698
procmail: Unlocking "/usr/mailfilters/doc.lock"
procmail: Executing " (formail -rt ; \
echo "Your e-mail was bounced!" \
) | sendmail -oi -t"
procmail: [3586] Fri Feb 15 10:04:22 2002
procmail: Error while writing to " (formail -rt ; \
echo "Your e-mail was bounced!" \
) | sendmail -oi -t"
procmail: Assigning "LASTFOLDER= (formail -rt ; \
echo "Your e-mail was bounced!" \
) | sendmail -oi -t"
procmail: Assigning
"PATH=/root/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin"
From npalmqvist(_at_)shipco(_dot_)com Fri Feb 15 10:04:21 2002
Subject: Test...
Folder: /var/spool/mail/root
21698
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail