using procmail/formail to save listmail to folder
using procmail/formail to save listmail to folder
am 11.05.2007 19:55:19 von rawlins02
I'm trying to set up procmail and formail to move emails from email
lists to a particular directory. I'm trying to do this by using
formail and egrep on header strings which match items in a file. The
second block below are a few of the records in the file which is
specified in .procmailrc like so:
MAILDIR=$HOME/mail
PMDIR=$MAILDIR/procmail_stuff
MAILLISTS=$PMDIR/listmail.list
Example records in listmail.list:
*@delta.com
dividendmiles@myusairways.com
esaver@myusairways.com
@scientific-direct.net
Here are the commands in .procmailrc
:0:
* ? formail -x"From" -x"From:" -x"Sender:" \
-x"Reply-To:" -x"Return-Path:" -x"To" \
| egrep -is -f $MAILLISTS
$LISTBOX
My problem is that all good mail that gets through my spam filter is
going to the directory $LISTBOX
Here there something obviously wrong with the syntax of my formail or
egrep commands.
Mike
Re: using procmail/formail to save listmail to folder
am 12.05.2007 16:03:05 von Alan Clifford
On Fri, 11 May 2007, rawlins02@yahoo.com wrote:
r> Example records in listmail.list:
r>
r> *@delta.com
r> dividendmiles@myusairways.com
r> esaver@myusairways.com
r> @scientific-direct.net
r>
r> Here are the commands in .procmailrc
r> :0:
r> * ? formail -x"From" -x"From:" -x"Sender:" \
r> -x"Reply-To:" -x"Return-Path:" -x"To" \
r> | egrep -is -f $MAILLISTS
r> $LISTBOX
r>
r> My problem is that all good mail that gets through my spam filter is
r> going to the directory $LISTBOX
r>
r> Here there something obviously wrong with the syntax of my formail or
r> egrep commands.
r>
In the first instance, I'd have a look at what you are actually getting
with the formail. Put it in a variable and log it, with verbose logging
on. Just cutting and pasting from bits of my own rather than manipulating
to fit you situation:
NL="
"
OLDVERBOSE=${VERBOSE:-off}
VERBOSE=on
FROMHEADER=`formail -c -rtz -x To:`
LOG="${NL}Fromt: ${FROMHEADER}${NL}"
VERBOSE=${OLDVERBOSE}
You can then go on to use the variable if your recipe if you want
:0
* ? echo "${FROMHEADER}" | grep -E -is -f "${REWHITELIST}"
--
Alan
( If replying by mail, please note that all "sardines" are canned.
However, unless this a very old message, a "tuna" will swim right
through. )
Re: using procmail/formail to save listmail to folder
am 14.05.2007 16:44:54 von rawlins02
On May 12, 10:03 am, Alan Clifford wrote:
> On Fri, 11 May 2007, rawlin...@yahoo.com wrote:
>
> r> Example records in listmail.list:
> r>
> r> *...@delta.com
> r> dividendmi...@myusairways.com
> r> esa...@myusairways.com
> r> @scientific-direct.net
> r>
> r> Here are the commands in .procmailrc
> r> :0:
> r> * ? formail -x"From" -x"From:" -x"Sender:" \
> r> -x"Reply-To:" -x"Return-Path:" -x"To" \
> r> | egrep -is -f $MAILLISTS
> r> $LISTBOX
> r>
> r> My problem is that all good mail that gets through my spam filter is
> r> going to the directory $LISTBOX
> r>
> r> Here there something obviously wrong with the syntax of my formail or
> r> egrep commands.
> r>
>
> In the first instance, I'd have a look at what you are actually getting
> with the formail. Put it in a variable and log it, with verbose logging
> on. Just cutting and pasting from bits of my own rather than manipulating
> to fit you situation:
>
> NL="
> "
> OLDVERBOSE=${VERBOSE:-off}
> VERBOSE=on
> FROMHEADER=`formail -c -rtz -x To:`
> LOG="${NL}Fromt: ${FROMHEADER}${NL}"
> VERBOSE=${OLDVERBOSE}
>
> You can then go on to use the variable if your recipe if you want
>
> :0
> * ? echo "${FROMHEADER}" | grep -E -is -f "${REWHITELIST}"
>
> --
> Alan
>
> ( If replying by mail, please note that all "sardines" are canned.
> However, unless this a very old message, a "tuna" will swim right
> through. )
Alan:
Here is what I got by pasting the commands into .procmail. So, if I
have a list of email addresses like fakeuser@fakedomain.com or
@somedomain.com in the file designated $MailList, how would move the
emails with From: matching a string in the file? Still not clear to
me.
procmail: [28305] Mon May 14 09:35:50 2007
procmail: Executing "formail,-c,-rtz,-x,To:"
procmail: [28305] Mon May 14 09:35:50 2007
procmail: Assigning "FROMHEADER=fakeuser@fakedomain.com"
procmail: Assigning "LOG=Fromt: fakeuser@fakedomain.com"
Fromt: fakeuser@fakedomain.comprocmail: Assigning "VERBOSE=off"
REWHITELIST: Undefined variable.
procmail: Missing action
Re: using procmail/formail to save listmail to folder
am 14.05.2007 21:39:40 von Alan Clifford
On Mon, 14 May 2007, rawlins02@yahoo.com wrote:
r>
r> Alan:
r> Here is what I got by pasting the commands into .procmail. So, if I
r> have a list of email addresses like fakeuser@fakedomain.com or
r> @somedomain.com in the file designated $MailList, how would move the
r> emails with From: matching a string in the file? Still not clear to
r> me.
r>
r> procmail: [28305] Mon May 14 09:35:50 2007
r> procmail: Executing "formail,-c,-rtz,-x,To:"
r> procmail: [28305] Mon May 14 09:35:50 2007
r> procmail: Assigning "FROMHEADER=fakeuser@fakedomain.com"
r> procmail: Assigning "LOG=Fromt: fakeuser@fakedomain.com"
r> Fromt: fakeuser@fakedomain.comprocmail: Assigning "VERBOSE=off"
r> REWHITELIST: Undefined variable.
r> procmail: Missing action
r>
r>
You didn't put in an action line. Here it is again with an action line -
I put a header into the email as well to tell me which recipe has done the
business. I think I have defined all the variables. You will have to make
sure that the path and file name that ${MAILLISTS} points to are suitable
for your setup.
This is just an example. You will have to change the ${FROMHEADER}
formail stuff to do what you want it to do.
# -------- cut here -----------#
OLDVERBOSE=${VERBOSE:-off}
VERBOSE=on
NL="
"
SPAMSTATUS_HEADER="X-Rawlins-Spamcheck-Status: "
MAILLISTS=${PMDIR}/listmail.list
FROMHEADER=`formail -c -rtz -x To:`
LOG="${NL}Fromt: ${FROMHEADER}${NL}"
# Is from: in the regular expression MAILLISTS?
:0
* ? echo "${FROMHEADER}" | grep -E -is -f "${MAILLISTS}"
{
# Replace the marker
:0 fhwa
| formail -I "${SPAMSTATUS_HEADER}from: in the regular expression white list"
:0:
${DEFAULT}
}
VERBOSE=${OLDVERBOSE}
# -------- cut here -----------#
--
Alan
( If replying by mail, please note that all "sardines" are canned.
However, unless this a very old message, a "tuna" will swim right
through. )
Re: using procmail/formail to save listmail to folder
am 14.05.2007 23:19:27 von rawlins02
On May 14, 3:39 pm, Alan Clifford wrote:
> On Mon, 14 May 2007, rawlin...@yahoo.com wrote:
>
> r>
> r> Alan:
> r> Here is what I got by pasting the commands into .procmail. So, if I
> r> have a list of email addresses like fakeu...@fakedomain.com or
> r> @somedomain.com in the file designated $MailList, how would move the
> r> emails with From: matching a string in the file? Still not clear to
> r> me.
> r>
> r> procmail: [28305] Mon May 14 09:35:50 2007
> r> procmail: Executing "formail,-c,-rtz,-x,To:"
> r> procmail: [28305] Mon May 14 09:35:50 2007
> r> procmail: Assigning "FROMHEADER=fakeu...@fakedomain.com"
> r> procmail: Assigning "LOG=Fromt: fakeu...@fakedomain.com"
> r> Fromt: fakeu...@fakedomain.comprocmail: Assigning "VERBOSE=off"
> r> REWHITELIST: Undefined variable.
> r> procmail: Missing action
> r>
> r>
>
> You didn't put in an action line. Here it is again with an action line -
> I put a header into the email as well to tell me which recipe has done the
> business. I think I have defined all the variables. You will have to make
> sure that the path and file name that ${MAILLISTS} points to are suitable
> for your setup.
>
> This is just an example. You will have to change the ${FROMHEADER}
> formail stuff to do what you want it to do.
> # -------- cut here -----------#
> OLDVERBOSE=${VERBOSE:-off}
> VERBOSE=on
> NL="
> "
> SPAMSTATUS_HEADER="X-Rawlins-Spamcheck-Status: "
> MAILLISTS=${PMDIR}/listmail.list
> FROMHEADER=`formail -c -rtz -x To:`
> LOG="${NL}Fromt: ${FROMHEADER}${NL}"
>
> # Is from: in the regular expression MAILLISTS?
> :0
> * ? echo "${FROMHEADER}" | grep -E -is -f "${MAILLISTS}"
> {
> # Replace the marker
> :0 fhwa
> | formail -I "${SPAMSTATUS_HEADER}from: in the regular expression white list"
>
> :0:
> ${DEFAULT}}
>
> VERBOSE=${OLDVERBOSE}
> # -------- cut here -----------#
>
Below is what's now produced in procmail.log. Still not clear to me
how I make procmail run through a list of strings in $MAILLISTS and
move any email that is from any of those entries to a directory
specified in .procmailrc like so: LISTBOX=$MAILDIR/ListMail. Do I need
to use formail,-c,-rtz,-x,To: ?
Is :0 fhwa the action? Does egrep not come into play for this? And I
don't see anything in the log file related to:
formail -I "${SPAMSTATUS_HEADER}from: in the regular expression white
list"
Here's the output in procmail.log
procmail: Assigning "NL=
"
procmail: Assigning "SPAMSTATUS_HEADER=X-Rawlins-Spamcheck-Status: "
procmail: Executing "formail,-c,-rtz,-x,To:"
procmail: Assigning "FROMHEADER=fakeuser@fakedomain.com"
procmail: Assigning "LOG=
Fromt:fakeuser@fakedomain.com
"